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.
require'trello'Trello.configuredo|config|# API key generated by visiting https://trello.com/1/appKey/generateconfig.developer_public_key=ENV['PUBLIC_KEY']# Member token# larry-price.com/blog/2014/03/18/connecting-to-the-trello-api/config.member_token=ENV['MEMBER_TOKEN']end
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.
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.