DEV Community

Louis Bertin
Louis Bertin

Posted on

Download all Flickr photos of a user with only 20 lines of Python 🐍


Today, a friend wanted to download all photos of a photograph he likes a lot on Flickr.. but that's a long and a boring task.. especially when the user has many photos.

So, I just asking myself how I can automate this task.. and Python is the answer!


  • Python and Pip (the higher is better!)
  • venv : optional, but I advise you to use it.

Let's jump into the code!

  • At the root of your working directory run the following command to install flickr_api as a dependency
pip install flickr_api
  • Next you have to create an account on Flickr and log you in to get your api_key and your api_secret with the following link
  • Then use this code and replace API_KEY, API_SECRET and USER_NAME with your credentials πŸ™‚
import os
import flickr_api

flickr_api.set_keys(api_key = 'API_KEY', api_secret = 'API_SECRET')
os.makedirs(os.path.join(os.getcwd(), "photos"), exist_ok=True)

user = flickr_api.Person.findByUserName("USER_NAME")
pages_nb = user.getPublicPhotos().info.pages
total = user.getPublicPhotos()
current = 0

for page_nb in range(1, pages_nb+1):
    for index, photo in enumerate(user.getPublicPhotos(page=page_nb)):
        sizes = photo.getSizes()
        biggest_size = list(sizes.keys())[-1]
        filename = photo.title.replace("/", "-") + "_" +

        current += 1
            print(f"{current}/{total}", filename)
  , "photos", filename), size_label = biggest_size)
        except Exception as e:

Top comments (0)