Skip to main content

Python Flickr API

PyPI version Python 3.10+ License

An object-oriented Python wrapper for the Flickr REST API.

This library provides Pythonic access to Flickr through domain objects like Photo, Person, Gallery, and Photoset rather than raw API calls. It covers almost the entire Flickr API.

Note: This package is flickr_api on PyPI. The similarly named flickrapi is a different package by a different author.

Installation

pip install flickr_api

Requires Python 3.10 or later.

Quick Start

1. Get API Keys

Apply for API keys at Flickr App Garden. You'll receive an API key and secret.

2. Configure the Library

import flickr_api

flickr_api.set_keys(api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET")

3. Start Using It

Fetch a user's public photos:

user = flickr_api.Person.findByUserName("username")
photos = user.getPhotos()

for photo in photos:
    print(photo.title)

Search for photos by tag:

photos = flickr_api.Photo.search(tags="sunset", per_page=10)

Authentication for Write Operations

Read-only operations (searching, fetching public data) only need API keys. To upload, edit, or access private content, you'll need OAuth authentication:

# One-time setup: get authorization URL
auth_handler = flickr_api.auth.AuthHandler()
url = auth_handler.get_authorization_url("write")
print(f"Visit this URL and authorize: {url}")

# After user authorizes, set the verifier
auth_handler.set_verifier("VERIFIER_CODE_FROM_FLICKR")
flickr_api.set_auth_handler(auth_handler)

# Save credentials for later
auth_handler.save("flickr_auth.txt")
# In future sessions, load saved credentials
auth_handler = flickr_api.auth.AuthHandler.load("flickr_auth.txt")
flickr_api.set_auth_handler(auth_handler)

Now you can upload photos and create albums:

# Upload a photo
flickr_api.upload(photo_file="vacation.jpg", title="Beach sunset", tags="vacation beach")

# Create an album
photo = flickr_api.Photo.search(user_id="me")[0]
photoset = flickr_api.Photoset.create(title="Vacation 2024", primary_photo=photo)

Features

  • Object-oriented interface - Work with Photo, Person, Photoset, Gallery, and other domain objects
  • Comprehensive API coverage - Access to nearly all Flickr API methods
  • OAuth 1.0a authentication - Secure authentication for write operations
  • Flexible method arguments - Pass either objects or IDs:
    photo.addTag(tag=tag_object)    # Using object
    photo.addTag(tag_id="12345")    # Using ID string
    
  • Built-in caching - Django-compatible cache interface to reduce API calls
  • Direct API access - Bypass objects and call the Flickr API directly when needed:
    flickr_api.flickr.photos.search(tags="test")
    

Documentation

For more detailed documentation, see the docs/ folder:

Projects Using This Library

Have a project using this library? Open a PR to add it here!

Development

This project uses uv for dependency management.

# Install dependencies
uv sync --dev

# Run tests
uv run pytest

# Run linter
uv run flake8 flickr_api/

Contributing

Bug reports, feature requests, and pull requests are welcome on GitHub.

Metadata

Release files for flickr-api 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flickr-api 0.8.1
File Size Uploaded
flickr_api-0.8.1.tar.gz 305.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flickr-api 0.8.1
File Interpreter ABI Platform
flickr_api-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 425.7 kB

Release files / flickr_api-0.8.1.tar.gz

Download URL flickr_api-0.8.1.tar.gz
Size 305.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4843c6a3bbe676ab67320dcf01b86af5d27c3e547baa9efb9ae2232e75be99d1
BLAKE2b-256 checksum
How to use checksums
18f1e18091ad3622b7bd9019a4de69c70c3c7e1c11395ecc5171128a9b5c0e15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / flickr_api-0.8.1-py3-none-any.whl

Download URL flickr_api-0.8.1-py3-none-any.whl
Size 119.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5670ce40244ce61878ee1f46666ac090cba041d4ad2b2257a9fcef610b61541
BLAKE2b-256 checksum
How to use checksums
5ae00c7594c64c8964923d55f01d444e159d883a54aa2d9e53ebf0f93e3bf5ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 release files

0.8.0

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

1 release file

0.6.1

2 release files

0.6

1 release file

0.5

1 release file

0.4

0.3

2 release files

0.2

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page