Marko Anastasov wrote this on May 13, 2010

Using Flickr API with Ruby and r2flickr

If you want to use Flickr API with Ruby, there are plenty of options. The one we’ve been using for a long time was rflickr by Trevor Schroeder, which is an implementation that matches the Flickr API as it is officially documented. However, it was unmaintained in RubyForge’s svn repo, and it needed some fixes, so we eventually published r2flickr. You can install it as a regular gem:

sudo gem install r2flickr

Here’s a hint on how you can search for photos with a certain tag and get some information about each of them:

flickr = Flickr.new(FLICKR_CACHE_PATH, FLICKR_API_KEY, FLICKR_SHARED_SECRET)

photos = flickr.photos.search(
  :tags => "sunrise",
  :per_page => 20, :page => 1,
  :sort => "date-posted-desc"
)

photos.each do |photo|
  info = photo.flickr.photos.getInfo(photo.id)
  puts "#{info.title} from #{info.ownername}"
  puts photo.url('t')
end

For more details, check out the project on GitHub.

comments powered by Disqus

About Marko Anastasov

Marko co-founded Rendered Text. He’s a programmer with a passion of creating something for other people, coupled with interests in how things work in the society and nature. He is having a great time working across many areas in the company, including product design, helping the engineering teams, empowering users and marketing. He likes to counterbalance it all with running, cycling or a day in the woods.

Suggested Reads

Inject is a fundamental building block

Inject is one of the fundamental, and most versatile constructs available in functional languages. It can be used to implement map, select, max, all? and a bunch of other iteration related methods. Unfortunately, many programmers are not aware of its awesome powers. This article is here to improve this fact.

Contact

Rendered Text is a software company. For questions regarding Semaphore, please visit semaphoreci.com. Otherwise, feel free to get in touch any time by sending us an email.

Rendered Text
Svetozara Miletica 10
21000 Novi Sad
Serbia