Announcing Python APIs

chirayuchirayu Registered Users Posts: 5 Beginner grinner
Hi,

I am pleased to share Python functional API's for Smugmug. API's are hosted at http://code.google.com/p/smugmug-api/.

The python API's use REST and provide a functional interface to the Smugmug API. They are agnostic to the contents of the response and in that sense the API's are future proof (of course the software using the API's will be affected by changes).

Examples

Each method in the Smugmug API is translated into a function by removing the preceding smugmug, and replacing the "." with "_". So, smugmug.users.getTree becomes users_getTree.

The parameters of the functions take the same name as the arguments of the method. The following is a call to retrieve album statistics - API.albums_getStats (SessionID=session_id, AlbumID=album["id"], Month="1", Year="2007")

Examples to showcase the API are located in the examples/ directory in the smug_func_ops.py file. Examples include - display random image, download an album, get the most popular image. To get a random image, you can use "python smug_func_ops.py -m random_image -e <your email> -p <your password>"

What is missing?
  • Search
  • Upload (update: added)
  • Caching framework to deal with downloaded images
UPDATE:
Original post is modified to reflect modified file names and to clarify out that these are functional API's

Have fun,
Chirayu

Comments

  • gymshotsgymshots Registered Users Posts: 20 Big grins
    edited December 6, 2007
    version of the API?
    Chirayu,

    I was curious if you have support for v1.2.1 APIs. I was having trouble with the pro pricing, image rotation and watermarking in v1.2.1 using xml-rpc.

    have you tried those?
    thanks,
    Susan Jones
    chirayu wrote:
    Hi,

    I am pleased to share Python API's for Smugmug. API's are hosted at http://code.google.com/p/smugmug-api/.

    The python API's use REST and provide a functional interface to the Smugmug API. They are agnostic to the contents of the response and in that sense the API's are future proof (of course the software using the API's will be affected by changes).

    Examples

    Each method in the Smugmug API is translated into a function by removing the preceding smugmug, and replacing the "." with "_". So, smugmug.users.getTree becomes users_getTree.

    The parameters of the functions take the same name as the arguments of the method. The following is a call to retrieve album statistics - API.albums_getStats (SessionID=session_id, AlbumID=album["id"], Month="1", Year="2007")

    Examples to showcase the API are located in the examples/ directory in the smugmug_ops.py file. Examples include - display random image, download an album, get the most popular image.

    What is missing?
    • Search
    • Upload
    • Caching framework to deal with downloaded images
    Have fun,
    Chirayu
  • chirayuchirayu Registered Users Posts: 5 Beginner grinner
    edited December 7, 2007
    Hi Susan,

    The API's support 1.2.1.

    I have added an example in the smugmug_ops.py file to demonstrate the rotation functionality (see function rotate_image_45 in file smugmug_ops.py)

    To debug the calls, I sometimes use the commandline. To test the rotation functionality, I did

    curl 'http://api.smugmug.com/services/api/rest/1.2.1/?method=smugmug.images.rotate&APIKey=29qIYnAB9zHcIhmrqhZ7yK7sPsdfoV0e&SessionID=<your session id>&Degrees=30&ImageID=<your image id>'

    About the other calls, I don't have a Pro account to try them out. Sorry.

    Hope this helps,
    CP
    P.S: I added the upload functionality today morning.
    gymshots wrote:
    Chirayu,

    I was curious if you have support for v1.2.1 APIs. I was having trouble with the pro pricing, image rotation and watermarking in v1.2.1 using xml-rpc.

    have you tried those?
    thanks,
    Susan Jones
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited December 11, 2007
    chirayu wrote:
    About the other calls, I don't have a Pro account to try them out. Sorry.

    You do now thumb.gif
    David Parry
    SmugMug API Developer
    My Photos
  • chirayuchirayu Registered Users Posts: 5 Beginner grinner
    edited December 11, 2007
    Thanks devbobo. That was quick.
    devbobo wrote:
    You do now thumb.gif
  • MarilynMarilyn Registered Users Posts: 6 Beginner grinner
    edited December 30, 2008
    Missing documentation?
    Hi chirayu,

    Thanks for this!clap.gif

    I'm only at the reading-documentation stage and the README.txt says:

    1. Refer to the documentation in the beginning of the
    smugmugapi/__init__.py file.
    deal.gif
    Actually, that was google's only hit on smugmugapi/__init__.py

    Sometimes tools ignore __init__.py files, so maybe that's why I can't find it? Or maybe I'm missing something.
    bowdown.gif
    Could you please provide the documentation in another way, or give me a hint about how to find it?

    Thanks for any help.

    Marilyn
Sign In or Register to comment.