Advertisement
AnonymousHaxs

Trello API

Oct 20th, 2015
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.89 KB | None | 0 0
  1. --[[
  2. IF YOU DONT KNOW HOW TO SCRIPT GET OUT YOU WONT KNOW HOW TO USE THIS!
  3. When something returns a table try running a recruisive loop to see what is inside the table
  4. If Private board then follow this
  5. -Instructions
  6. 1. Go to this link and click allow: https://trello.com/1/authorize?key=aded73d328dce4a0698a6744856b3326&name=Roblox+Api&expiration=never&response_type=token&scope=read,write
  7. 2. Copy the random numbers and letters in the page sent to you
  8. 3. Paste the random numbers and letters in the Value of Token
  9. 4. If anywhere an error occurs when in use with "Unauthorized" you didnt copy the full link!
  10. -Functions
  11. --------------
  12. GetBoardID([Board Name]) return Board ID
  13. --------------
  14. GetListID([List Name],[Board ID]) return List ID
  15. --------------
  16. GetCardID([Name],[Board ID]) returns Card ID
  17. --------------
  18. GetBoardInfo([Board ID]) returns a table like this except not JSON
  19. {
  20. "id": "4eea4ffc91e31d1746000046",
  21. "name": "Example Board",
  22. "desc": "This board is used in the API examples",
  23. "lists": [{
  24. "id": "4eea4ffc91e31d174600004a",
  25. "name": "To Do Soon"
  26. }, {
  27. "id": "4eea4ffc91e31d174600004b",
  28. "name": "Doing"
  29. }, {
  30. "id": "4eea4ffc91e31d174600004c",
  31. "name": "Done"
  32. }]
  33. }
  34. --------------
  35. GetCardInfo([Card ID],[Board ID]) returns an table
  36. -----------
  37. GetLists([Board ID]) returns a table
  38. ------------
  39. AddCard([Name],[Decription],[List ID],Optional[AddUrl],Optional[Position **Valid Values: A position. top, bottom, or a positive number.**],Optional[Due*Default=null*],Optional[Label**Valid Values: all or a comma-separated list of: blue,green,orange,purple,red,yellow**],Optional[CardToCopyID]) returns a Table
  40. ------------
  41. AddList([Name],[Board ID],Optional[List to Copy],Optional[Position *Valid Values: position. top, bottom, or a positive number.*])
  42. ------------
  43. AddBoard([Name],[Description])
  44. ------------
  45. *DEPRICATED*AddLabelName([Board ID],[Name],[Color]) WILL BE REMOVED
  46. ------------
  47. AddCardAtt([Card ID],[Name],[File,URL],[Value])
  48. ------------
  49. AddLabel([Name],[Color],[Board ID]) returns Label ID
  50. ------------
  51. AddCardLabel([Card ID],[Label ID])
  52. ------------
  53. GetLabels([Board ID]) returns a table such as bellow except not in JSON
  54. [
  55. {"id":"559adc5e19ad3a5dc2b9c003","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"green","uses":0},
  56. {"id":"559adc5e19ad3a5dc2b9c004","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"yellow","uses":0},
  57. {"id":"559adc5e19ad3a5dc2b9c006","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"red","uses":0},
  58. {"id":"559adc5e19ad3a5dc2b9c007","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"purple","uses":0},
  59. {"id":"559adc5e19ad3a5dc2b9c008","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"blue","uses":0},
  60. ]
  61. ------------
  62. GetCardsInList([List ID]) returns a table containing the cards tables
  63. ------------
  64. PostComment([Card ID],Text)
  65. ------------
  66. AddCheckList()
  67. ------------
  68. GetLabelID(LabelName,BoardID) OUCH MY BACK!
  69. ]]--
  70. local Private=true
  71. local addon
  72. local HS=game:GetService("HttpService")
  73. local IS=game:GetService("InsertService")
  74. local T = {}
  75. function getAddon()
  76. if script.Token.Value~="" then
  77. addon="?key=aded73d328dce4a0698a6744856b3326&token="..script.Token.Value
  78. else
  79. error([[-Instructions
  80. \n 1. Go to this link and click allow: https://trello.com/1/authorize?key=aded73d328dce4a0698a6744856b3326&name=Roblox+Api&expiration=30days&response_type=token&scope=read,write
  81. \n 2. Copy the token in the page sent to you
  82. \n 3. Paste the token in the Value of Token]])
  83. end
  84. end
  85. --[[
  86. POST /1/cards/[card id or shortlink]/actions/comments
  87. Required permissions: comments
  88. Arguments
  89. text (required)
  90. Valid Values: a string with a length from 1 to 16384
  91. --]]
  92. function T:PostComment(cid,t)
  93. local url
  94. if Private then
  95. getAddon()
  96. url="https://api.trello.com/1/cards/"..tostring(cid).."/actions/comments"..addon
  97. else
  98. url="https://api.trello.com/1/cards/"..tostring(cid).."/actions/comments"..addon
  99. end
  100. local dat={
  101. text=t
  102. }
  103. local data=HS:JSONEncode(dat)
  104. local re=HS:PostAsync(url,data)
  105. local red=HS:JSONDecode(re)
  106. return red
  107. end
  108. --/1/lists/[idList]/cards
  109. --[[
  110. [{
  111. "id": "4eea503791e31d1746000080",
  112. "checkItemStates": [],
  113. "closed": false,
  114. "dateLastActivity": "2011-12-15T19:53:27.228Z",
  115. "desc": "",
  116. "descData": null,
  117. "email": null,
  118. "idAttachmentCover": null,
  119. "idBoard": "4eea4ffc91e31d1746000046",
  120. "idLabels": [],
  121. "idList": "4eea4ffc91e31d174600004a",
  122. "idMembersVoted": [],
  123. "idShort": 3,
  124. "manualCoverAttachment": false,
  125. "name": "Finish my awesome application",
  126. "pos": 65536,
  127. "shortLink": "XlG8S7ll",
  128. "badges": {
  129. "votes": 0,
  130. "viewingMemberVoted": false,
  131. "subscribed": false,
  132. "fogbugz": "",
  133. "checkItems": 0,
  134. "checkItemsChecked": 0,
  135. "comments": 0,
  136. "attachments": 0,
  137. "description": false,
  138. "due": null
  139. },
  140. "due": null,
  141. "idChecklists": [],
  142. "idMembers": [],
  143. "labels": [],
  144. "shortUrl": "https://trello.com/c/XlG8S7ll",
  145. "subscribed": false,
  146. "url": "https://trello.com/c/XlG8S7ll/3-finish-my-awesome-application"
  147. }]
  148. --]]
  149. function T:GetCardsInList(lid)
  150. local url
  151. if Private then
  152. getAddon()
  153. url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon
  154. else
  155. getAddon()
  156. url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon
  157. end
  158. local re=HS:GetAsync(url,true)
  159. local dat=HS:JSONDecode(re)
  160. return dat
  161. end
  162. --[[
  163. POST /1/labels
  164. Required permissions: write
  165. Arguments
  166. name (required)
  167. Valid Values: a string with a length from 0 to 16384
  168. color (required)
  169. Valid Values: A valid label color or null
  170. idBoard (required)
  171. Valid Values: An id
  172. --]]
  173. function T:AddLabel(nae,col,boardid)
  174. local url
  175. if Private then
  176. getAddon()
  177. url="https://api.trello.com/1/labels"..addon
  178. else
  179. url="https://api.trello.com/1/labels"..addon
  180. end
  181. local dat={
  182. name=nae,
  183. color=col,
  184. idBoard=boardid
  185. }
  186. local data=HS:JSONEncode(dat)
  187. local re=HS:PostAsync(url,data)
  188. --print(re)
  189. return (HS:JSONDecode(re)).id
  190. end
  191. --[[
  192. POST /1/cards/[card id or shortlink]/idLabels
  193. Required permissions: write
  194. Arguments
  195. value (required)
  196. Valid Values: The id of the label to add
  197. --]]
  198. function T:AddCardLabel(card,lid)
  199. local url
  200. local cardi=tostring(card)
  201. if Private then
  202. getAddon()
  203. url="https://api.trello.com/1/cards/"..cardi.."/idLabels"..addon
  204. else
  205. url="https://api.trello.com/1/cards/"..cardi.."/idLabels"..addon
  206. end
  207. --print(card,"IS THE CARD ID \n",lid,"IS THE LABEL ID")
  208. local da={
  209. value=lid
  210. }
  211. local dat=HS:JSONEncode(da)
  212. local data=HS:PostAsync(url,dat)
  213. --print(data)
  214. return HS:JSONDecode(data)
  215. end
  216. --[[
  217. POST /1/boards
  218. Required permissions: write
  219. Arguments
  220. name (required)
  221. Valid Values: a string with a length from 1 to 16384
  222. desc (optional)
  223. Valid Values: a string with a length from 0 to 16384
  224. idOrganization (optional)
  225. Valid Values: The id or name of the organization to add the board to.
  226. idBoardSource (optional)
  227. Valid Values: The id of the board to copy into the new board
  228. keepFromSource (optional)
  229. Default: all
  230. Valid Values: Components of the source board to copy.
  231. powerUps (optional)
  232. Valid Values: all or a comma-separated list of:
  233. calendar
  234. cardAging
  235. recap
  236. voting
  237. prefs_permissionLevel (optional)
  238. Default: private
  239. Valid Values: One of:
  240. org
  241. private
  242. public
  243. prefs_voting (optional)
  244. Default: disabled
  245. Valid Values: One of:
  246. disabled
  247. members
  248. observers
  249. org
  250. public
  251. prefs_comments (optional)
  252. Default: members
  253. Valid Values: One of:
  254. disabled
  255. members
  256. observers
  257. org
  258. public
  259. prefs_invitations (optional)
  260. Default: members
  261. Valid Values: One of:
  262. admins
  263. members
  264. prefs_selfJoin (optional)
  265. Default: true
  266. Valid Values:
  267. true
  268. false
  269. prefs_cardCovers (optional)
  270. Default: true
  271. Valid Values:
  272. true
  273. false
  274. prefs_background (optional)
  275. Default: blue
  276. Valid Values: a string with a length from 0 to 16384
  277. prefs_cardAging (optional)
  278. Default: regular
  279. Valid Values: One of:
  280. pirate
  281. regular
  282. --]]
  283. function T:AddBoard(nae,dec)
  284. local url
  285. if Private then
  286. getAddon()
  287. url="https://api.trello.com/1/boards"..addon
  288. else
  289. getAddon()
  290. url="https://api.trello.com/1/boards"..addon
  291. end
  292. local dat={
  293. name=nae,
  294. desc=dec
  295. }
  296. local data=HS:JSONEncode(dat)
  297. local re=HS:PostAsync(url,data)
  298. local red=HS:JSONDecode(re)
  299. return red
  300. end
  301. function T:GetCardID(name,boardid)
  302. local url
  303. if Private then
  304. getAddon()
  305. url="https://api.trello.com/1/boards/"..boardid.."/cards"..addon
  306. else
  307. getAddon()
  308. url="https://api.trello.com/1/boards/"..boardid.."/cards"..addon
  309. end
  310. local tab=HS:GetAsync(url,true)
  311. local tabl=HS:JSONDecode(tab)
  312. for k,ta in pairs(tabl) do
  313. for p,t in pairs(ta) do
  314. if p=="name" and t==name then
  315. return ta.id
  316. end
  317. end
  318. end
  319. end
  320. function T:GetCardInfo(cardid)
  321. --/1/boards/[board_id]/cards/[idCard]
  322. local url
  323. if Private then
  324. getAddon()
  325. url="https://api.trello.com/1/cards/"..cardid..""..addon
  326. else
  327. getAddon()
  328. url="https://api.trello.com/1/cards/"..cardid..""..addon
  329. end
  330. local re=HS:GetAsync(url,true)
  331. local tab=HS:JSONDecode(re)
  332. return tab
  333. end
  334. function T:GetBoardInfo(boardid)
  335. local url
  336. if Private then
  337. getAddon()
  338. url="https://api.trello.com/1/members/my/boards/"..boardid..addon
  339. else
  340. getAddon()
  341. url="https://api.trello.com/1/members/my/boards/"..boardid..addon
  342. end
  343. local re=HS:GetAsync(url,true)
  344. local data=HS:JSONDecode(re)
  345. return data
  346. end
  347. function T:GetLists(boardid)
  348. local url
  349. if Private then
  350. getAddon()
  351. url="https://api.trello.com/1/members/my/boards/"..boardid.."/lists"..addon
  352. else
  353. getAddon()
  354. url="https://api.trello.com/1/members/my/boards/"..boardid.."/lists"..addon
  355. end
  356. local re=HS:GetAsync(url,true)
  357. local data=HS:JSONDecode(re)
  358. return data
  359. end
  360. function T:GetBoardID(name)
  361. local url
  362. if Private then
  363. getAddon()
  364. url="https://api.trello.com/1/members/my/boards"..addon
  365. else
  366. getAddon()
  367. url="https://api.trello.com/1/members/my/boards"..addon
  368. end
  369. local tball=HS:GetAsync(url,true)
  370. local dt=HS:JSONDecode(tball)
  371. for _,tab in pairs(dt) do
  372. for p,it in pairs(tab) do
  373. if p=="name" and it==name then
  374. return tab.id
  375. end
  376. end
  377. end
  378. error(name.." not found!")
  379. return nil
  380. end
  381. --[[
  382. POST /1/cards
  383. Required permissions: write
  384. Arguments
  385. name (optional)
  386. Valid Values: The name of the new card. It isn't required if the name is being copied from provided by a URL, file or card that is being copied.
  387. desc (optional)
  388. Valid Values: a string with a length from 0 to 16384
  389. pos (optional)
  390. Default: bottom
  391. Valid Values: A position. top, bottom, or a positive number.
  392. due (required)
  393. Valid Values: A date, or null
  394. labels (optional)
  395. Valid Values: all or a comma-separated list of:
  396. blue
  397. green
  398. orange
  399. purple
  400. red
  401. yellow
  402. idList (required)
  403. Valid Values: id of the list that the card should be added to
  404. idMembers (optional)
  405. Valid Values: A comma-separated list of objectIds, 24-character hex strings
  406. idLabels (optional)
  407. Valid Values: A comma-separated list of objectIds, 24-character hex strings
  408. urlSource (required)
  409. Valid Values: A URL starting with http:// or https:// or null
  410. fileSource (optional)
  411. Valid Values: A file
  412. idCardSource (optional)
  413. Valid Values: The id of the card to copy into a new card.
  414. keepFromSource (optional)
  415. Default: all
  416. Valid Values: Properties of the card to copy over from the source.
  417.  
  418. --]]
  419. function T:AddCard(...)
  420. local url
  421. local args={...}
  422. local dat
  423. if #args==3 then
  424. local nam,des,lid=args[1],args[2],args[3]
  425. dat={
  426. name=nam,
  427. desc=des.."",
  428. idList=lid,
  429. urlSource=nil,
  430. due=nil
  431. }
  432. elseif #args==4 then
  433. local nam,des,lid,url=args[1],args[2],args[3],args[4]
  434. dat={
  435. name=nam,
  436. desc=""..des,
  437. idList=lid,
  438. urlSource=url,
  439. due=nil
  440. }
  441. elseif #args==5 then
  442. local nam,des,lid,url,po=args[1],args[2],args[3],args[4],args[5]
  443. dat={
  444. name=nam,
  445. desc=""..des,
  446. idList=lid,
  447. urlSource=url,
  448. pos=po,
  449. due=nil
  450. }
  451. elseif #args==6 then
  452. local nam,des,lid,url,po,de=args[1],args[2],args[3],args[4],args[5],args[6]
  453. dat={
  454. name=nam,
  455. desc=""..des,
  456. idList=lid,
  457. urlSource=url,
  458. pos=po,
  459. due=de
  460. }
  461. elseif #args==7 then
  462. local nam,des,lid,url,po,de,label=args[1],args[2],args[3],args[4],args[5],args[6],args[7]
  463. dat={
  464. name=nam,
  465. desc=""..des,
  466. idList=lid,
  467. urlSource=url,
  468. pos=po,
  469. due=de,
  470. labels=label
  471. }
  472. elseif #args==8 then
  473. local nam,des,lid,url,po,de,label,cc=args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]
  474. dat={
  475. name=nam,
  476. desc=""..des,
  477. idList=lid,
  478. urlSource=url,
  479. pos=po,
  480. due=de,
  481. labels=label,
  482. idCardSource=cc
  483. }
  484. end
  485. local data=HS:JSONEncode(dat)
  486. if Private then
  487. getAddon()
  488. url="https://api.trello.com/1/cards"..addon
  489. else
  490. getAddon()
  491. url="https://api.trello.com/1/cards"..addon
  492. end
  493. local re=HS:PostAsync(url,data)
  494. return HS:JSONDecode(re)
  495. end
  496. --[[
  497. POST /1/cards/[card id or shortlink]/attachments
  498. Required permissions: write
  499. Arguments
  500. file (optional)
  501. Valid Values: A file
  502. url (optional)
  503. Valid Values: A URL starting with http:// or https:// or null
  504. name (optional)
  505. Valid Values: a string with a length from 0 to 256
  506. mimeType (optional)
  507. Valid Values: a string with a length from 0 to 256
  508. --]]
  509. function T:AddCardAtt(cardid,nae,type,value)
  510. local url
  511. local dat
  512. if string.lower(type)=="file" then
  513. dat={
  514. name=nae,
  515. file=value
  516. }
  517. elseif string.lower(type)=="url" then
  518. dat={
  519. name=nae,
  520. url=value
  521. }
  522. elseif string.lower(type)=="mime" then
  523. dat={
  524. name=nae,
  525. mimeType=value
  526. }
  527. end
  528. local cardi=tostring(cardid)
  529. if Private then
  530. getAddon()
  531. url="https://api.trello.com/1/cards/"..cardi.."/attachments"..addon
  532. else
  533. getAddon()
  534. url="https://api.trello.com/1/cards/"..cardi.."/attachments"..addon
  535. end
  536. local data=HS:JSONEncode(dat)
  537. local re=HS:PostAsync(url,data)
  538. return re
  539. end
  540. --[[
  541. GET /1/boards/[board_id]/labels
  542. Required permissions: read
  543. Arguments
  544. fields (optional)
  545. Default: all
  546. Valid Values: all or a comma-separated list of:
  547. color
  548. idBoard
  549. name
  550. uses
  551. limit (optional)
  552. Default: 50
  553. Valid Values: a number from 0 to 1000
  554. --]]
  555. function T:GetLabels(boardid)
  556. local url
  557. local dat
  558. if Private then
  559. getAddon()
  560. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  561. else
  562. getAddon()
  563. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  564. end
  565. local re=HS:GetAsync(url,true)
  566. --print(re)
  567. local dat=HS:JSONDecode(re)
  568. return dat
  569. end
  570. --[[
  571. GET /1/boards/[board_id]/labels
  572. Required permissions: read
  573. Arguments
  574. fields (optional)
  575. Default: all
  576. Valid Values: all or a comma-separated list of:
  577. color
  578. idBoard
  579. name
  580. uses
  581. limit (optional)
  582. Default: 50
  583. Valid Values: a number from 0 to 1000
  584. --]]
  585. function T:GetLabelID(LabelName,boardid)
  586. local url
  587. local dat
  588. if Private then
  589. getAddon()
  590. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  591. else
  592. getAddon()
  593. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  594. end
  595. local re=HS:GetAsync(url,true)
  596. --print(re)
  597. local dat=HS:JSONDecode(re)
  598. local id
  599. for i,v in next,dat do
  600. if v.name==LabelName then
  601. id=v.id
  602. break
  603. end
  604. end
  605. return id
  606. end
  607.  
  608. --[[
  609. GET /1/boards/[board_id]/lists
  610. Required permissions: read
  611. Arguments
  612. cards (optional)
  613. Default: none
  614. Valid Values: One of:
  615. all
  616. closed
  617. none
  618. open
  619. visible
  620. card_fields (optional)
  621. Default: all
  622. Valid Values: all or a comma-separated list of:
  623. badges
  624. checkItemStates
  625. closed
  626. dateLastActivity
  627. desc
  628. descData
  629. due
  630. email
  631. idAttachmentCover
  632. idBoard
  633. idChecklists
  634. idLabels
  635. idList
  636. idMembers
  637. idMembersVoted
  638. idShort
  639. labels
  640. manualCoverAttachment
  641. name
  642. pos
  643. shortLink
  644. shortUrl
  645. subscribed
  646. url
  647. filter (optional)
  648. Default: open
  649. Valid Values: One of:
  650. all
  651. closed
  652. none
  653. open
  654. fields (optional)
  655. Default: all
  656. Valid Values: all or a comma-separated list of:
  657. closed
  658. idBoard
  659. name
  660. pos
  661. subscribed
  662. --]]
  663. function T:GetListID(name,boardid)
  664. local url
  665. if Private then
  666. getAddon()
  667. url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
  668. else
  669. getAddon()
  670. url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
  671. end
  672. local tab=HS:GetAsync(url,true)
  673. local tabl=HS:JSONDecode(tab)
  674. for k,ta in pairs(tabl) do
  675. for p,t in pairs(ta) do
  676. if p=="name" and t==name then
  677. return ta.id
  678. end
  679. end
  680. end
  681. end
  682. --[[
  683. POST /1/lists
  684. Required permissions: write
  685. Arguments
  686. name (required)
  687. Valid Values: a string with a length from 1 to 16384
  688. idBoard (required)
  689. Valid Values: id of the board that the list should be added to
  690. idListSource (optional)
  691. Valid Values: The id of the list to copy into a new list.
  692. pos (optional)
  693. Default: top
  694. Valid Values: A position. top, bottom, or a positive number.
  695. --]]
  696. function T:AddList(...)
  697. local args={...}
  698. local nam,boid,idsource,po
  699. local url
  700. local dat
  701. if #args==2 then
  702. nam,boid=args[1],args[2]
  703. dat={name=nam,idBoard=boid}
  704. elseif #args==3 then
  705. nam,boid,idsource=args[1],args[2],args[3]
  706. dat={name=nam,idBoard=boid,idListSource=idsource}
  707. elseif #args==4 then
  708. nam,boid,idsource,po=args[1],args[2],args[3],args[4]
  709. dat={name=nam,idBoard=boid,idListSource=idsource,pos=po}
  710. else
  711. error("Invalid arguments: "..table.concat(args,","))
  712. end
  713. --
  714. if Private then
  715. getAddon()
  716. url="https://api.trello.com/1/lists"..addon
  717. else
  718. getAddon()
  719. url="https://api.trello.com/1/lists"..addon
  720. end
  721. local data=HS:JSONEncode(dat)
  722. local re=HS:PostAsync(url,data)
  723. return re.id
  724. end
  725. return T
  726. -----------------------------------------[[
  727. REMEMBER TO MAKE THE TOKEN]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement