Pythonista and Trello - Part 3 Inserting Cards

This is the next post in the series.  Part 3 is all about inserting cards into a list on a board.  I have one board name Today and I use this as the main board to insert everything into, then from there I can move things around as I see fit, this is in effect my Inbox.

In Part 1 we got the Key and the token to connect it up, and in Part 2 we got a list of all our boards.

So now we tackle inserting cards, in this example I am opening a file and processing it line by line to create the cards.  First thing we need to do is to get the board ID.  You can easily find this, when you are in the board, look at the url and this will be the random characters before the name of the board, it will be like, the bold characters is the board name.

Once you have the board name, you need to get the lists, this way you can see list names and again you can get the id we will use to insert the cards to.  Once you have the board ID you need to construct a url like this one, this will then show all the lists.  Depending on your browser you will either see the json or it will download it, which ever it is you will see something like this.


The id is the one on the left of the name, you need to make a copy of this as this is the list you are inserting into to.  Now we have everything, you will need the code.

# Script Name	:
# Author	: Craig Richards
# Created	: 27th July 2017
# Last Modified	: 27th July 2017
# Version	: 1.1

# Modifications	: 1.1 - 27/07/17 - CR - Added line to use web browswer to go back to drafts

# Description	: This will process the actions from the meeting notes 

import requests   
import json      
from dropboxlogin import get_client
import webbrowser


cards_url = ''

params_key_and_token = {'key':key,'token':token}

dropbox_client = get_client()


file = open (listfile, "r")
for text in file.readlines():
	name = text
	description = 'Add your own description'
	id_list = '5978f876f483fbe536d37d70'
	arguments = {'name': name,'desc': description,'idList' : id_list}

	response =, params=params_key_and_token, data=arguments)"drafts4://")

So what's happening.  The first part downloads actions.txt from Dropbox and stores them on my iOS device inside Pythonista.  The reason I write out to actions.txt is I write in drafts and and use workflow to create templates to use for differnt meetings etc, so any action I have in meeting notes etc if I prefix the line with @ then it pulls them out into actions.txt to be processed.

Once it has the file, it reads it and for each line it will create a new card on the list, you add a default description, or you could like I might change is to put the date and the time as the description so I can see when it was created.  This will also work on other workflows and drafts actions that I can just process a list I can type.

I am always interested in your thoughts so if you have any comments or feedback then please feel free to add any comments, or you can mail me  here.

Related Posts Plugin for WordPress, Blogger... 


Game of Thrones Name Generator