Flickr (formerly FlickRaw) is a library to access the Flickr API in a simple way. It maps exactly the methods described in the official API documentation. It also tries to present the data returned in a simple and intuitive way. The methods are fetched from Flickr when loading the library by using introspection capabilities. So it is always up-to-date with regards to new methods added by Flickr.

The github repository:

Upgrading from FlickRaw?

If you're upgrading from FlickRaw 0.9.x there are a few breaking changes to be aware of:

  • Instantiate a new object with client = instead of
  • The global flickr variable is no longer created.
  • Local caching of the Flickr API specification is no longer achieved with a separate gem.


Type this in a console (you might need to be superuser)

gem install flickr

This will recreate the documentation by fetching the method descriptions from Flickr and then virtually plugging them in standard rdoc documentation.

$ cd flickr
$ rake rdoc


  • Minimal dependencies
  • Complete support of Flickr API. This doesn't require an update of the library
  • Ruby syntax similar to the Flickr API
  • Flickr authentication
  • HTTPS Support
  • Photo upload
  • Proxy support
  • Flickr URLs helpers


Getting started

To use the Flickr API, you must first obtain an API key and shared secret from Flickr. You can do this by logging in to Flickr and creating an application here. API keys are usually granted automatically and instantly.

require 'flickr'

# The credentials can be provided as parameters:


# Alternatively, if the API key and Shared Secret are not provided, Flickr will attempt to read them
# from environment variables:

flickr =

# Flickr will raise an error if either parameter is not explicitly provided, or available via environment variables.


list   =

id     = list[0].id
secret = list[0].secret
info   = :photo_id => id, :secret => secret

puts info.title           # => "PICT986"
puts info.dates.taken     # => "2006-07-06 15:16:18"

sizes = :photo_id => id

original = sizes.find { |s| s.label == 'Original' }
puts original.width       # => "800" -- may fail if they have no original marked image


token = flickr.get_request_token
auth_url = flickr.get_authorize_url(token['oauth_token'], :perms => 'delete')

puts "Open this url in your browser to complete the authentication process: #{auth_url}"
puts "Copy here the number given when you complete the process."
verify = gets.strip

  flickr.get_access_token(token['oauth_token'], token['oauth_token_secret'], verify)
   = flickr.test.
  puts "You are now authenticated as #{.username} with token #{flickr.access_token} and secret #{flickr.access_secret}"
rescue Flickr::FailedResponse => e
  puts "Authentication failed : #{e.msg}"

If the user has already been authenticated, you can reuse the access token and access secret:

flickr.access_token = "... Your access token ..."
flickr.access_secret = "... Your access secret ..."

# From here you are logged:
 = flickr.test.
puts "You are now authenticated as #{.username}"

If you need to have several users authenticated at the same time in your application (ex: a public web application) you need to create separate Flickr objects since it keeps the authentication data internally.

flickr =


PHOTO_PATH = 'photo.jpg'

# You need to be authenticated to do that, see the previous examples.
flickr.upload_photo PHOTO_PATH, :title => "Title", :description => "This is the description"


The first time the Flickr object is instantiated, it will download the current Flickr API definition and dynamically create all the required classes and objects. This is how the gem remains up-to-date without requiring updates.

Unfortunately this adds a significant delay to startup, but the Flickr gem can be configured to cache the API definition to a local file. Just set a file location before the Flickr class is instantiated:

Flickr.cache = '/tmp/flickr-api.yml'
flickr =


require 'flickr'
Flickr.proxy = "https://user:[email protected]:3129/"

Server Certificate Verification

Server certificate verification is enabled by default. If you don't want to check the server certificate:

require 'flickr'
Flickr.check_certificate = false

CA Certificate File Path

OpenSSL::X509::DEFAULT_CERT_FILE is used as a CA certificate file. If you want to change the path:

require 'flickr'
Flickr.ca_file = '/path/to/cacert.pem'

You can also specify a path to a directory with a number of certifications:

Flickr.ca_path = '/path/to/certificates'

Flickr URL Helpers

There are some helpers to build Flickr urls:

url, url_m, url_s, url_t, url_b, url_z, url_q, url_n, url_c, url_o

# url_s : Square
# url_q : Large Square
# url_t : Thumbnail
# url_m : Small
# url_n : Small 320
# url   : Medium
# url_z : Medium 640
# url_c : Medium 800
# url_b : Large
# url_o : Original

info = => "3839885270")
Flickr.url_b(info) # => ""


info = => "3839885270")
Flickr.url_profile(info) # => "[email protected]/"


info = => "3839885270")
Flickr.url_photopage(info) # => "[email protected]/3839885270"

url_photoset, url_photosets

info = => "3839885270")
Flickr.url_photosets(info) # => "[email protected]/sets/"

url_short, url_short_m, url_short_s, url_short_t

info = => "3839885270")
Flickr.url_short(info) # => ""


info = => "3839885270")
Flickr.url_photostream(info) # => "[email protected]/"


See the examples directory to find more examples.