Pythonista and Trello - Part 2 Get a list of boards

This is the next in the mini-series of how I connect Pythonista and Python to Trello to push and pull information.  In Part 1 I showed you how to get your key and your token to allow you to access your Trello account.

This code will collect all of the boards you have, even if they are archived boards, now as this is a first try there must be a way to only get open boards.  Because I found this out when I first ran this, I fully closed/deleted the boards I had archived.

Any recent boards that I have finished with before I archive them I now rename them by pre-fixing ARC - before the board name, this way my code can filter these out.

The Python code is below

# Script Name		: trelloboards.py
# Author	 	: Craig Richards
# Created		: 27th July 2017
# Last Modified		: 
# Version		: 1.0

# Modifications		: 

# Description		: This will get a list of all the project boards

import requests     
import json        
from pprint import pprint

key = 'YOUR KEY GOES HERE'
token = 'YOUR TOKEN GOES HERE'

base = 'https://trello.com/1/'
boards_url = base + 'members/me/boards'

params_key_and_token = {'key':key,'token':token}
arguments = {'fields': 'name'}
response = requests.get(boards_url, params=params_key_and_token, data=arguments)

response_array_of_dict = response.json()

for board in response_array_of_dict:
	if not board['name'].startswith('ARC'):
	  print board['name']

If you are also interested I have provided another one you can get a list of your Trello boards, this will work your iOS device as long as you have Workflow installed.  This collects a list of the boards then saves them to  new draft in Drafts for iOS, you could always change this to write out to another app of you choice.

You can download this by clicking on the following link,  Get Project List From Trello 

In Part 3 we will insert cards to the boards.

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

Pythonista and Trello - Part 1 Key and Token