This library implements the TrelloAPI.
Trello is an awesome tool for organization. Not just aimed at developers, but everybody. Seriously, check it out.
# gem install ruby-trello Full Disclosure: This library is mostly complete, if you do find anything missing or not functioning as you expect it to, please let us know.
While this library still does function on ruby 1.8 as of version 1.0.2 with activemodel < 4.0, this notice services to illustrate that future versions may include ruby 1.9.3+ specific features.
Basic authorization:
- Get your API keys from trello.com/app-key.
- Visit the URL [trello.com/1/authorize], with the following GET parameters:
key: the API key you got in step 1.response_type: "token"expiration: "never" if you don't want your token to ever expire. If you leave this blank, your generated token will expire after 30 days.- The URL will look like this:
https://trello.com/1/authorize?key=YOURAPIKEY&response_type=token&expiration=never
- You should see a page asking you to authorize your Trello application. Click "allow" and you should see a second page with a long alphanumeric string. This is your member token.
require'trello'Trello.configuredo |config| config.developer_public_key=TRELLO_DEVELOPER_PUBLIC_KEY# The "key" from step 1config.member_token=TRELLO_MEMBER_TOKEN# The token from step 3.end2-legged OAuth authorization
Trello.configuredo |config| config.consumer_key=TRELLO_CONSUMER_KEYconfig.consumer_secret=TRELLO_CONSUMER_SECRETconfig.oauth_token=TRELLO_OAUTH_TOKENconfig.oauth_token_secret=TRELLO_OAUTH_TOKEN_SECRETend3-legged OAuth authorization
Trello.configuredo |config| config.consumer_key=TRELLO_CONSUMER_KEYconfig.consumer_secret=TRELLO_CONSUMER_SECRETconfig.return_url="http://your.site.com/path/to/receive/post"config.callback=lambda{ |request_token| DB.save(request_token.key,request_token.secret)}endAll the calls this library make to Trello require authentication using these keys. Be sure to protect them.
So lets say you want to get information about the user bobtester. We can do something like this:
bob=Trello::Member.find("bobtester")# Print out his nameputsbob.full_name# "Bob Tester"# Print his bioputsbob.bio# A wonderfully delightful test user# How about a list of his boards?bob.boardsApplications that make requests on behalf of multiple Trello users have an alternative to global configuration. For each user's access token/secret pair, instantiate a Trello::Client:
@client_bob=Trello::Client.new(:consumer_key=>YOUR_CONSUMER_KEY,:consumer_secret=>YOUR_CONSUMER_SECRET,:oauth_token=>"Bob's access token",:oauth_token_secret=>"Bob's access secret")@client_alice=Trello::Client.new(:consumer_key=>YOUR_CONSUMER_KEY,:consumer_secret=>YOUR_CONSUMER_SECRET,:oauth_token=>"Alice's access token",:oauth_token_secret=>"Alice's access secret")You can now make threadsafe requests as the authenticated user:
Thread.newdo@client_bob.find(:members,"bobtester")@client_bob.find(:boards,"bobs_board_id")endThread.newdo@client_alice.find(:members,"alicetester")@client_alice.find(:boards,"alices_board_id")endA special thanks goes out to Ben Biddington who has contributed a significant amount of refactoring and functionality to be deserving of a beer and this special thanks.
Several ways you can contribute. Documentation, code, tests, feature requests, bug reports.
We develop ruby-trello using Trello itself.
Please see the CONTRIBUTING.md file for more information.


