How to load data from Trello to Redshift

Extract your data from Trello

Trello exposes a very rich API to developers. It is the same API that is used internally to build the web and mobile Trello apps that we all use and love. It is possible to build a completely new application on top of the API using the different components and resources that it exposes, or just use it to pull out data as we plan to do in our case.

The Trello API follows the RESTful principles and it can be accessed through HTTP. As a RESTful API, interacting with it can be achieved by using tools like CURL or Postman or by using http clients for your favourite language or framework. A few suggestions:

Trello also offers an official Javascript client/wrapper for its API, that can be found here. It is also possible to find numerous other unofficial SDKs, all it takes is a quick search on Google or Github.

Trello API Authentication

Authentication and Authorization are supported by the Trello API by implementing the OAuth protocol. It’s important to understand that the Authentication Token, obtained through the oAuth workflow execution, gives your application the ability to make calls on behalf of your user, from their context. This token grants access to the authenticated user’s boards, lists, cards, and other settings, depending on the permissions you requested in the authenticate method. So you have to handle it with care.

Trello rate limiting

To help prevent strain on Trello’s servers, our API imposes rate limits per API key for all issued tokens. There is a limit of 300 requests per 10 seconds for each API key and no more than 100 requests per 10-second interval for each token. If a request exceeds the limit, Trello will return a 429 error.

Endpoints and available resources

The Trello API exposes a large number of resources together with their associated HTTP endpoints that allow the users to interact with the platform as the web and mobile applications of Trello do. The most important resources are the following:

  • Board: anything related to the boards a user can create and manage in Trello
  • Card: operations about the cards that can be created inside boards
  • Checklist: it allows the creation and manipulation of checklists inside cards
  • Label: operations related to labels that can be created inside cards
  • List: operations on lists
  • Member: operations related to members of a board
  • Notification: operations about the notification system of the platform
  • Organization: manage organizations inside Trello

Let’s assume that you have a board that helps you track one of your projects, the methodology doesn’t matter at this points, what is important is that you most probably will have cards associate to tasks, and these cards are holding the information that you would like to pull, store in a database like Amazon Redshift and analyze it further. First, we assume that we know the ID of our board, for e.g. 4eea4ffc91e31d1746000046. First, we want to get all the lists that this board includes. To do that, we execute a GET request on the following URL:

JAVASCRIPT
https://api.trello.com/1/boards/4eea4ffc91e31d1746000046/lists?cards=open&card_fields=name&fields=name&key=[application_key]&token=[optional_auth_token]

If the request is successful we will get back a response like the following:

JAVASCRIPT
[{
"id": "4eea4ffc91e31d174600004a",
"name": "To Do Soon",
"cards": [{
"id": "4eea503791e31d1746000080",
"name": "Finish my awesome application"
}]
}, {
"id": "4eea4ffc91e31d174600004b",
"name": "Doing",
"cards": [{
"id": "4eea503d91e31d174600008f",
"name": "Learn about the Trello API"
}, {
"id": "4eea522c91e31d174600027e",
"name": "Figure out how to read a user's board list"
}]
}, {
"id": "4eea4ffc91e31d174600004c",
"name": "Done",
"cards": [{
"id": "4eea501f91e31d1746000062",
"name": "Get a key to use in my API requests"
}, {
"id": "4eea502b91e31d1746000071",
"name": "Find out where the Trello API documentation is"
}]
}]

The above JSON response includes all the lists that our product has. Each least will contain cards with tasks and for example, if we have a card inside the “Done” list it means that the associated task is completed.

After we get a list of all the lists we can start fetching the cards of each list. Again we do that by executing a GET request to the appropriate endpoint, using the IDs of the lists that we have extracted from the previous response. A typical URL for fetching the cards of a list looks like the following:

JAVASCRIPT
https://api.trello.com/1/lists/4eea4ffc91e31d174600004a/cards?key=[application_key]&token=[optional_auth_token]

And the result of a successful request to the above endpoint will result to something with the following structure:

JAVASCRIPT
[{
"id": "4eea503791e31d1746000080",
"badges": {
"votes": 0,
"viewingMemberVoted": false,
"subscribed": false,
"fogbugz": "",
"checkItems": 0,
"checkItemsChecked": 0,
"comments": 0,
"attachments": 0,
"description": false,
"due": null
},
"checkItemStates": [],
"closed": false,
"dateLastActivity": "2011-12-15T19:53:27.228Z",
"desc": "",
"descData": null,
"due": null,
"email": null,
"idAttachmentCover": null,
"idBoard": "4eea4ffc91e31d1746000046",
"idChecklists": [],
"idLabels": [],
"idList": "4eea4ffc91e31d174600004a",
"idMembers": [],
"idMembersVoted": [],
"idShort": 3,
"labels": [],
"manualCoverAttachment": false,
"name": "Finish my awesome application",
"pos": 65536,
"shortLink": "XlG8S7ll",
"shortUrl": "https://trello.com/c/XlG8S7ll",
"subscribed": null,
"url": "https://trello.com/c/XlG8S7ll/3-finish-my-awesome-application"
}]

We have retrieved all the relevant to our project information from our board. We just need to remodel our data in an appropriate way for us to query it on a database like Amazon Redshift and of course, ensure that we properly load the data to it. After we do that we are ready to start querying our Trello data and learning everything related to the performance of our teams and projects.

Prepare your Trello Data for Amazon Redshift

Amazon Redshift is built around industry-standard SQL with added functionality to manage very large datasets and high performance analysis. So, in order to load your data into it you will have to follow its data model which is a typical relational database model. The data you extract from your data source should be mapped into tables and columns. Where you can consider the table as a map to the resource you want to store and columns the attributes of that resource. Also, each attribute should adhere to the data types that are supported by Redshift, currently the data types that are supported are the following:

  • SMALLINT
  • INTEGER
  • BIGINT
  • DECIMAL
  • REAL
  • DOUBLE PRECISION
  • BOOLEAN
  • CHAR
  • VARCHAR
  • DATE
  • TIMESTAMP

As your data comes in a representation like JSON that supports a much smaller range of data types you have to be really careful about what data you feed into Redshift and make sure that you have mapped your types into one of the data types that is supported by Redshift.

Designing a Schema for Redshift and mapping the data from your data source to it is a process that you should take seriously as it can both affect the performance of your cluster and the questions that you can answer. It’s always a good idea to have in your mind the best practices that Amazon has published regarding the design of a Redshift database.

When you have concluded on the design of your database you need to load your data on one of the data sources that are supported as input by Redshift, these are the following:

Load data from Trello to Redshift

The first step to load your data from Trello to Redshift, is to put them in a source that Redshift can pull it from. As it was mentioned earlier there are three main data sources supported, Amazon S3, Amazon DynamoDB and Amazon Kinesis Firehose, with Firehose being the most recent addition as a way to insert data into Redshift.

To upload your data to Amazon S3 you will have to use the AWS REST API, as we see again APIs play an important role in both the extraction but also the loading of data into our data warehouse. The first task that you have to perform is to create a bucket, you do that by executing an HTTP PUT on the Amazon AWS REST API endpoints for S3. You can do this by using a tool like CURL or Postman. Or use the libraries provided by Amazon for your favourite language. You can find more information by reading the API reference for the Bucket operations on Amazon AWS documentation.

After you have created your bucket you can start sending your data to Amazon S3, using again the same AWS REST API but by using the endpoints for Object operations. As in the Bucket case you can either access the HTTP endpoints directly or use the library of your preference.

DynamoDB imports data again from S3, it adds another step between S3 and Amazon Redshift so if you don’t need it for other reasons you can avoid it.

Amazon Kinesis Firehose is the latest addition as a way to insert data into Redshift and offers a real time streaming approach into data importing. The necessary steps for adding data to Redshift through Kinesis Firehose are the following:

  1. Create a delivery stream
  2. Add data to the stream

whenever you add new data to the stream, Kinesis takes care of adding these data to S3 or Redshift, again going through S3 in this case is redundant if your goal is to move your data to Redshift. The execution of the previous two steps can be performed either through the REST API or through your favourite library just as in the previous two cases. The difference here is that for pushing your data into the stream you’ll be using a Kinesis Agent.

Amazon Redshift supports two methods for loading data into it. The first one is by invoking an INSERT command. You can connect to your Amazon Redshift instance with your client, using either a JDBC or ODBC connection and then you perform an INSERT command for your data.

JAVASCRIPT
insert into category_stage values
(12, 'Concerts', 'Comedy', 'All stand-up comedy performances');

The way you invoke the INSERT command is the same as you would do with any other SQL database, for more information you can check the INSERT examples page on the Amazon Redshift documentation.

Redshift is not designed for INSERT-like operations, on the contrary, the most efficient way of loading data into it is by doing bulk uploads using a COPY command. You can perform a COPY command for data that lives as flat files on S3 or from an Amazon DynamoDB table. When you perform COPY commands, Redshift is able to read multiple files in simultaneously and it automatically distributes the workload to the cluster nodes and performs the load in parallel. As a command COPY is quite flexible and allows for many different ways of using it, depending on your use case. Performing a COPY on amazon S3 is as simple as the following command:

JAVASCRIPT
copy listing
from 's3://mybucket/data/listing/'
credentials 'aws_access_key_id=;aws_secret_access_key=';

For more examples on how to invoke a COPY command you can check the COPY examples page on Amazon Redshift documentation. As in the INSERT case, the way to perform the COPY command is by connecting to your Amazon Redshift instance using a JDBC or ODBC connection and then invoke the commands you want using the SQL Reference from Amazon Redshift documentation.

The best way to load data from Trello to Amazon Redshift and possible alternatives

So far, we just scraped the surface of what can be done with Amazon Redshift and how to load data into it. The way to proceed relies heavily on the data you want to load, from which service they are coming from, and the requirements of your use case. Things can get even more complicated if you want to integrate data coming from different sources. A possible alternative, instead of writing, hosting, and maintaining a flexible data infrastructure, is to use a product like RudderStack that can handle this kind of problems automatically for you.

RudderStack integrates with multiple sources or services like databases, CRM, email campaigns, analytics, and more. Quickly and safely move all your data from Trello into Amazon Redshift and start generating insights from your data.

Sign Up For Free And Start Sending Data
Test out our event stream, ELT, and reverse-ETL pipelines. Use our HTTP source to send data in less than 5 minutes, or install one of our 12 SDKs in your website or app.