PDA

View Full Version : Announcing Python APIs


chirayu
Dec-06-2007, 01:49 AM
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 imagesUPDATE:
Original post is modified to reflect modified file names and to clarify out that these are functional API's

Have fun,
Chirayu

gymshots
Dec-06-2007, 08:35 PM
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

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 imagesHave fun,
Chirayu

chirayu
Dec-06-2007, 09:27 PM
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.

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

devbobo
Dec-11-2007, 12:40 AM
About the other calls, I don't have a Pro account to try them out. Sorry.

You do now :thumb

chirayu
Dec-11-2007, 12:50 AM
Thanks devbobo. That was quick.

You do now :thumb

Marilyn
Dec-30-2008, 01:31 PM
Hi chirayu,

Thanks for this!:clap

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
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.
:bow
Could you please provide the documentation in another way, or give me a hint about how to find it?

Thanks for any help.

Marilyn