So, you want to gather data using the Trello API so that you can do something cool with it? And you’re using Ruby? Enter ruby-trello. Install!
We’ll start off easy, and assume that we’re writing a personal application where we only need to access data for one user at a time. We start by configuring ruby-trello. I’m going to assume that you’ve already generated a public key and received a member token and stored them in your environment.
1 2 3 4 5 6 7 8 9 10
This connects me to a specific member as found through
ENV['MEMBER_TOKEN']. I previously wrote another post about getting a member token from a user.
For demonstration, I’ll find myself, grab my first board, and then display the name, names of lists, members who have worked on the project, and some numbers about each of the cards in the board. This is essentially my proof of concept for a super-cool web-app I wrote called Ollert.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Wow, cool! Such data! This is really great for a single user because we only have to make the connection to Trello once (which is not incredibly fast). However, this won’t work in a multi-user environment since we configured ruby-trello to use a specific member token. So how do we connect to multiple members at a time? Let’s print out the same data we did above for a single user, but using
Trello::Client to connect to Trello.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Now, as your friend and teacher, I command you to use this knowledge to go do cool stuff with Trello!