Announcing Python APIs
chirayu
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?
Original post is modified to reflect modified file names and to clarify out that these are functional API's
Have fun,
Chirayu
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
Original post is modified to reflect modified file names and to clarify out that these are functional API's
Have fun,
Chirayu
0
Comments
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
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.
You do now
SmugMug API Developer
My Photos
Hi chirayu,
Thanks for this!
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.
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.
Could you please provide the documentation in another way, or give me a hint about how to find it?
Thanks for any help.
Marilyn