Finding the exact URL of a Flickr photo given its ID

flickr

How can I automatically retrieve the exact URL of a Flickr photo when I pass the ID to the API?

I have the IDs of all pictures and I'm currently using the flickr.photos.getInfo method that takes the ID as parameter and it gives me an XML file with the picture page URL as an answer.

However the picture page URL is not the URL of the picture (which is displayed in this page).

How can I automatically retrieve the exact URL of the picture?

Best Answer

From the Official Flickr documentation:

Photo Source URLs

You can construct the source URL to a photo once you know its ID, server ID, farm ID and secret, as returned by many API methods.

The URL takes the following format:

http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg
or
http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstzb].jpg
or
http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)