Trello » TrelloSimple A very simple helper for the Trello API in Python Read More
Clone URL:  
readme.md
View Markdown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
##Quick Example Instead of mapping every API command to Python, TrelloSimple makes it easy to work with the [existing documentation](https://trello.com/docs/) to interact with the API: Here's an example of [getting a board](https://trello.com/docs/api/board/index.html#get-1-boards-board-id): >>> from trelloSimple import TrelloSimple >>> trello = TrelloSimple(TRELLO_APP_KEY) #get key at https://trello.com/1/appKey/generate# >>> trello.get(['boards','4d5ea62fd76aa1136000000c']) {u'name': u'Trello Development', u'idOrganization': u'4e1452614e4b8698470000e0', u'url': u'https://trello.com/board/trello-development/4d5ea62fd76aa1136000000c' , u'closed': False, u'prefs': {u'permissionLevel': u'public', u'voting': u'publi c', u'cardCovers': True, u'comments': u'public', u'invitations': u'members'}, u' id': u'4d5ea62fd76aa1136000000c', u'desc': u'Trello board used by the Trello tea m to track work on Trello. How meta!\n\nThe development of the Trello API is be ing tracked at https://trello.com/api\n\nThe development of Trello Mobile applic ations is being tracked at https://trello.com/mobile'} Here's an example of getting a private board. First, get the token url: >>> trello.get_token_url('My App') https://trello.com/1/authorize?key=TRELLO_APP_KEY&name=My+App&expiration=30days&response_type=token&scope=read,write Copy the URL that prints out and navigate to it in the browser. Authorize the app and copy the auth token that is returned, which will be referred to as `TOKEN` below. Here's an example of [changing the description on a board](https://trello.com/docs/api/board/index.html#put-1-boards-board-id), which requires that the token be set: >>> trello.set_token(TOKEN) >>> trello.put(['boards',BOARD_ID],arguments={'desc':'changed the description'}) --- ##Detailed Explanation TrelloSimple allows you to look at the documentation for any API command and easily map what you want to send. Here's the basic syntax: trello.[method_name](array_of_url_pieces,dictionary_of_arguments) For example, if you wanted to comment on a card via the API, first you would look up in the [documentation on how to comment on a card](https://trello.com/docs/api/card/index.html#post-1-cards-card-id-or-shortlink-actions-comments). This is a POST, so this means I'm going to start with: trello.post( Next, I look at the url pieces that are required, which are (ignoring the `1`, which is the api version) `cards/[card id or shortlink]/actions/comments`. I'll need to add an array with those pieces: trello.post(['cards',CARD_ID,'actions','comments'] Lastly, I'll need to supply any arguments as a dictionary. In the case of this example, there's only one argument to specify, `text`: trello.post(['cards',CARD_ID_OR_SHORT_LINK,'actions','comments'],{'text':'This is a comment.'}) That's it! ##Etc. If you would rather provide a formatted string for `urlPieces`, you can do that as well, e.g. `trello.get('boards/4d5ea62fd76aa1136000000c')` instead of trello.get(['boards','4d5ea62fd76aa1136000000c']).