[Tutorial][Trello][API] How to create a board for every list on a starting board.

First off, and this is important: don’t name your .py file the same name as the library you’re going to import.

The way I did it was set up a virtual environment, so in vim I selected a directory and entered commands:

mkvirtualenv trellostuff

Then:

pip install trello

Then:

workon trellostuff

Now that’s all set up, on to creating a board. My specific problem was how to take all of the lists from one board and use those to create a board for each list.

Import libraries:

#!python
import trello

Create a “Board” object. I also create a “list” object by getting all the lists from the Board object “a”.

a = trello.Boards("key","token")
ls = a.get_list("board_identifier")
current_boards = {}

For every list in ls (so all the lists on a specific board as denoted by “board_identifier”):

for list in ls:

Create a new board with the name of the list (and put those into a dictionary with the names of the list as keys):

    current_boards[list['name']] = a.new(list['name'])

This should go to one board, take all the lists, and create new boards with the same names as each list.

This dictionary is useful because I don’t have the ids of these boards I just created, but thanks to this dictionary of boards, I can get access to them.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s