Skip to content

Getting started with flickrapi

Based on reading the  Python FlickrAPI, I wrote a simple example using the flickrapi library:

import flickrapi

if __name__ == '__main__':
    # instantiate the flickr object with the API_KEY, SECRET to return ElementTree entities
    flickr = flickrapi.FlickrAPI(api_key=API_KEY,secret=API_SECRET,format='etree')
    photos = flickr.photos_search(user_id='73509078@N00', per_page='10')

    if photos.attrib['stat']:
        for photo in photos.find('photos').getiterator('photo'):
            id = photo.attrib['id']
            secret = photo.attrib['secret']
            server_id = photo.attrib['server']
            farm_id = photo.attrib['farm']
            user_id = photo.attrib['owner']
            # calculate the thumbnail URL and photo URL
            thumbnail_url = "" \
                            % (farm_id, server_id, id, secret)
            photo_url = ""  % (user_id, id)
            print thumbnail_url, photo_url

Post a Comment

You must be logged in to post a comment.