DEV Community

loading...

5 Ways To Interact With Your Flickr Photos Using The Flickr API

jackhiston profile image Jack Histon ・3 min read

Flickr logo
image source - https://pixabay.com/en/flickr-logo-brand-yahoo-internet-881367/

A large supply of image data can be useful when it comes to many different software applications. In machine learning, training a program how to recognise an object in an image can be a hard problem to solve without training material. Flickr can become this training material. The Flickr API is a brilliant way to tap into image data.

To interact with the Flickr API, you will first need an API key. The api key can be generated by following the guide found here: https://www.flickr.com/services/api/misc.api_keys.html. For a bunch of useful resources discussing the Flickr API, see this wiki page: https://cloudinary.com/visualweb/display/IMMC/Flickr+API.

In this article, I will describe five ways in which the Flickr API can be beneficial to your software application. To keep things simple, I will use the curl command in my examples.

Searching for Photos

The main reason why you would want to interact with Flickr is to find images. Therefore, the most basic way to interact with Flickr API is by searching for photos. An image can be found by curling the follow url:

curl https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=&text=test&format=rest

Replacing with your own api key that you will have created from the introduction in this article. This will return you a list of photos in xml format that has a title, description, or tag with the value “test” in it. You can then find image data using the photo id in the response.

There are many filter options to choose from other than just text. To find out more ways to use each endpoint, visit the official documentation.

Getting Popular Photos

Another great way to interact with the Flickr API is by popularity of photo. The Flickr API can provide you with image data that is currently trending on their website, out of the box. This can be useful if you have software applications that require users to be kept up to date on certain images, etc.

curl https://api.flickr.com/services/rest/?method=flickr.photos.getPopular&api_key=&format=rest

Adding Photo Comments

Sometimes your software application might want to scan the vast volumes of data that Flickr has to offer. On other times, you might want to add or remove content. The next one I thought was interesting because it allows you to add metadata around your photos in the form of comments. Given a photo identifier, you can comment on any photo you want:

curl https://api.flickr.com/services/rest/?method=flickr.photos.comments.addComment&api_key=&photo_id=1&comment_text=test+comment&format=rest

This command will allow us to add a comment of “test comment” on the photo with id of 1. This can be great if your software application has to interact with user photos in real-time.

Geo-location Data

Sometimes you need to get access to all of the locations that you have taken photos on Flickr. This can be useful if you want to produce a picture map, where all your photos are juxtaposed onto a map of the earth.

curl https://api.flickr.com/services/rest/?method=flickr.photos.getWithGeoData&api_key=&format=rest

Retrieving Gallery Photos

Another way you can interact with your photos on Flickr API is through the use of galleries. A machine learning application could spend time being trained to understand how to categorise images of animals. After it has categorised them, the application can then add each individual photo into galleries. This is an example of how an application can be used to sort images into specific topics.

To list all the categories created by a user, you can use the following command:

curl https://api.flickr.com/services/rest/?method=flickr.galleries.getList&api_key=&user_id=1&format=rest

Conclusion

In this article, I have given you five different ways in which you can interact with the Flickr API for manipulating photo data. I hope you now see the versatility in the Flickr API, and what it can be used for to help you in building an application with rich imagery.

Sources of data are the currency of the internet. Data is what makes Google’s business model work, it is how machine’s can learn. Using something like the Flickr API can open your application up to a world of knowledge that can help your application be sophisticated and user-friendly.

Discussion (0)

pic
Editor guide