Python-Flickr
Python-Flickr is A Python library to interface with Flickr REST API & OAuth
Features
Photo Uploading
Retrieve user information
- Common Flickr methods
Add/edit/delete comments
Add/edit/delete notes
And many more (very dynamic library)!!
All responses return as nice dicts
Installation
Installing Python-Flickr is simple:
$ pip install python-flickr
Usage
Handling the Callback
# oauth_token and oauth_token_secret come from the previous step
# if needed, store those in a session variable or something
f = FlickrAPI(api_key='*your app key*',
api_secret='*your app secret*',
oauth_token=oauth_token,
oauth_token_secret=oauth_token_secret)
authorized_tokens = f.get_auth_tokens(oauth_verifier)
final_oauth_token = authorized_tokens['oauth_token']
final_oauth_token_secret = authorized_tokens['oauth_token_secret']
# Save those tokens to the database for a later use?
Getting the Users recent activity feed
# Get the final tokens from the database or wherever you have them stored
f = FlickrAPI(api_key='*your app key*',
api_secret='*your app secret*',
oauth_token=final_tokens['oauth_token'],
oauth_token_secret=final_tokens['oauth_token_secret'])
recent_activity = f.get('flickr.activity.userComments')
print recent_activity
Add comment on a photo
# Assume you are using the FlickrAPI instance from the previous section
add_comment = f.post('flickr.photos.comments.addComment',
params={'photo_id': '6620847285', 'comment_text': 'This is a test comment.'})
#This returns the comment id if successful.
print add_comment
Remove comment on a photo
# Assume you are using the FlickrAPI instance from the previous section
# If the comment is already deleted, it will throw a FlickrAPIError (In this case, with code 2: Comment not found.)
del_comment = f.post('flickr.photos.comments.deleteComment', params={'comment_id':'45887890-6620847285-72157628767110559'})
print del_comment
Upload a photo
# Assume you are using the FlickrAPI instance from the previous section
files = open('/path/to/file/image.jpg', 'rb')
add_photo = f.post(params={'title':'Test Title!'}, files=files)
print add_photo # Returns the photo id of the newly added photo
Catching errors
# Assume you are using the FlickrAPI instance from the previous section
try:
# This comment was already deleted
del_comment = f.post('flickr.photos.comments.deleteComment', params={'comment_id':'45887890-6620847285-72157628767110559'})
except FlickrAPIError, e:
print e.msg
print e.code
print 'Something bad happened :('
Metadata
Release files for python-flickr 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-flickr-0.3.2.tar.gz | 6.7 kB | Without provenance | Details for python-flickr-0.3.2.tar.gz |
Release files / python-flickr-0.3.2.tar.gz
| Download URL | python-flickr-0.3.2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
597962bb072d47b7b396cd999f37611fea33da02f14a168e7e3726fc7c12320a
|
|
BLAKE2b-256 checksum How to use checksums |
7075832a2c70df7b8b1c22d96cdf3df9bb801010b446ec2e8dd7cae3bb55e59a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for python-flickr 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.