Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A ruby gem wrapping Flattrs REST API
Pull request Compare This branch is 32 commits behind smgt:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Flattr gem Build Status Dependency Status

This gem is a wrapper around the Flattr API. With the gem you can search things, add new thing and much more. If you want information about updates follow @simongate on twitter.

Flattr this git repo


Installation is easy, just install the gem with.

gem install flattr



To talk with all of Flattr API resources you need to register a application. This will give you a client id and a client secret whom you can exchange for a access token. The access token is then used to access the resources in the Flattr API that needs authentication. You can find more information about the API in Flattr developer documents.


You can find documentation about available resources in the code.

Access public resources

There are several public available resources in the Flattr API where you don't need to authenticate to access.

# Fetch a public thing
flattr =

flattr.thing 423405
# => #<Flattr::Thing:0x007fccbb4f1d40 @attrs={"type"=>"thing", "resource"=>"", "link"=>"", "id"=>423405, "url"=>"", "language"=>"en_GB", "category"=>"text", "owner"=>{"type"=>"user", "resource"=>"", "link"=>"", "username"=>"flattr"}, "hidden"=>false, "created_at"=>1319704532, "tags"=>["api"], "flattrs"=>9, "description"=>"We have been working hard to deliver a great experience for developers and tried to build a good foundation for easily add new features. The API will remain in beta for a while for us to kill quirks and refine some of the resources, this means there might be big changes without notice for ...", "title"=>"API v2 beta out – what’s changed?"}>

Access protected resources

The gem allows makes it easy to do the oauth2 dance.

Flattr.configure do |config|
  config.client_id = '1234'
  config.client_secret = '4567'

flattr =

puts 'Open this URL in your browser to authenticate your application'
puts flattr.authorize_url

puts "\n\n"

puts 'When your with the authentication the browser will redirect you to the callback URL you specified when creating a application. It has also included a code in the query string. Copy paste this code to the command line.'
print 'code: '
code = gets

# Use the code and exchange it for a access_token
access_token = flattr.get_access_token code

puts access_token

# You are now authorized! ;)

Scopes available

If you request a access token without any scopes you won't be able to flattr other users things and such. The scopes available are:

  • thing - Create and update things
  • flattr - Flattr things
  • extendedread - Access all the information about users
  • email - Read the current users e-mail address

What needs to be done

  • Add all the Flattr API resources
  • More tests are needed, coverage isn't that good

Supported Ruby Versions

This library aims to support and is tested against the following Ruby implementations:

  • Ruby 1.8.7
  • Ruby 1.9.2
  • Ruby 1.9.3
  • JRuby
  • Rubinius
  • Ruby Enterprise Edition

If something doesn't work on one of these interpreters, it should be considered a bug.

This library may inadvertently work (or seem to work) on other Ruby implementations, however support will only be provided for the versions listed above.

If you would like this library to support another Ruby version, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be personally responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.


Copyright (c) 2011 Simon Gate, Joel Hansson. See LICENSE for details.

Something went wrong with that request. Please try again.