Get Trello Boards data with py-trello

Pull data from trello boards and output results in a DataFrame in python

Abonia Sojasingarayar
IBM Data Science in Practice
4 min readJul 9, 2022

--

Image by Author

In this article we will be discuss about the py-trello, a python wrapper around the Trello API and its usage. So we will be discussing :

  1. Py-Trello Overview
  2. Installation
  3. Usage
  4. Working with Trello Board
  5. Create a dataframe/Tabularize the data

1. Overview

A wrapper around the Trello API written in Python.This package automates most of the trello API calls with a line of code. We can get the list of boards available in trello, lists inside the board, Cards informations such as card name, description,activities, custom fields etc.

For more info py-trello official documentation and github repo.

2. Installation

pip

Use pip to install the Py-Trello library as follow:

conda-forge

To install py-trello and its core dependencies you can use:

3. Usage

Import trello client from trello package installed as in the above step. As like any other API client call we should provide API key, secret and token to establish the connection with trello.

For to get the connection information, sign in to trello developer account that you wish to work with and create your project.

4. Working with board

4.1 Get all the trello board

So from the below code we can work and access the boards information.Useclientlist_boards to list all the boards available in your trello account.

4.2. Get specific Board information

  • Get all the list in the board by specifying the board id as follows:
  • Get all the cards in the board by specifying the board id as follows:

4.3 Add description and comment

Add the decription and comment for a specified card using its id.Use card.set_descriptionto add the description and card.comment to add the comment.

4.4 Attach a file to Card

Attach the file in card as below by specifing its card id.Use card.attach to attach a file.Also mention path to the file you want to attach and name for the attachment.

5. Get the custom fields of Card in Dataframe

We can get the custom fields of the cards. Also we can get name of the custom field as column and value of custom field as column values of dataframe. This can be used for the further data analysis tasks.

So from the above code sample, we get a dataframe with columns such as Card Name, List Name, Custom field Names etc. Consider like every card in trello have the custom fields in order to get those data in a tabular format .

Here we consider only we have three list with each holding one card and all cards have the cutom fields. If there is no custom field the above code will let ‘NaN’ value in the place. The dataframe result will be as follow:

Dataframe with trello card custom fields as columns and its value as column value(Image by Author)

Conclusion:

In this article, we discuss about how py-trello facilitate the process of mining the trello board with minimum code. By using this library we can concentrate more time on data analysis and retriving the useful insight than scrapping and getting the data in first place.So see you all soon in my next article.

Ask your questions in comment and I will do my best to answer it.

Thank You for Reading

Connect with me on Linkedin

Find me on Github

Visit my technical channel on Youtube

Support: Buy me a Cofee/Chai

If you like this content, please dont forget to give your support by a clap. Be sure to SUBSCRIBE to never miss another article on data science topics, projects, guides and more!

--

--

Abonia Sojasingarayar
IBM Data Science in Practice

Principal Research Scientist | Machine Learning & Ops Engineer | Data Scientist | NLP Engineer | Computer Vision Engineer | AI Analyst