Developing with Flipper

Flipper is a Python wrapper to the Flickr API and as such stays close to the flickr format for accessing methods. Thus all methods are called exactly as specified at the Flickr API listing. The implemented methods are well documented as Python docstrings and thus this document only elaborates on some details such as authentication and setup.

Enabling Python to find Flipper

To install flipper you may install it following the steps in the Download page. If you want to use flipper as a library for your application and want to include it with your application then copy the flipper directory found in the 'src' directory in the flipper download to your application's root directory. Then you can use flipper through Python using the following Python import statement

from flipper import * #unfortunately import flipper doesn't work yet

Authentication

To access Flickr you will need to get a API key from http://www.flickr.com/services/api/misc.api_keys.html. Flickr has methods which require authentication and those which do not. In either case the API key and the shared secret is required. To set the API key you may either edit the flipperbase.py file in the flipper package or set it at the beginning of your program. The following code demonstrates setting the key and secret from an interactive prompt

>>> from flipper import *
>>> flipperbase.API_KEY = '<your key>'
>>> flipperbase.SHARED_SECRET = '<your secret>'

After that you may start using the methods not requiring authentication. All the methods have the same name as the Flickr API equivalents. So flickr.interestingness.getList becomes interestingness.getList in your code. Calling authenticated methods is a bit more complicated. The first time your application launches you should execute these commands after the above ones

auth.getFrob() #retrieves a frob from Flickr

#createLoginLink will return a string. You should ask the user
# to visit that url. There he will have to allow your application
# access to Flickr. You may pass permissions to createLoginLink.
#they may be 'read', 'write' or 'delete'(default)
auth.createLoginLink('write') # tell the user to go to this link

#after the user authenticates your application call getToken()
#getToken will get a new token from Flickr and store it in
# <user home>/.flickr/<api key>/auth.conf
# the next time it will just load it from here. You do not
#do anything
auth.getToken()