SmugMug JSON API 1.2.0 ExamplesThis section of the document will cover examples of queries to the SmugMug JSON API version 1.2.0 and the responses. In some of the Request and Response sections of the document values may be noted inside of tags, like <API KEY>, this simply indicates a private value that will either need to be provided by the developer or is part of the reply from SmugMug. Values spelled out using all-caps-underscore notation (e.g. INVALID_API_KEY) are literal values that can be used.
It's also important to note that every API call can be sent to
either the secure HTTPS URL or the unsecure HTTP URL. For the
purposes of examples and best-practices, all user login/logout
calls are suggested to be done against the secure HTTPS URL.
|
Error Codes
This section covers all the error responses that queries to the
different API methods can return. The
Request values below are just examples used in order to
cause the error to occur. For most errors (e.g. invalid session)
you can recieve them in many different ways, the examples below
do not cover every case.
You can detect any of these errors (and any undocumented) from any of the response implementations in this API or any custom response you choose to implement that extends com.kallasoft.smugmug.api.json.v1_2_0.Response. The implementation of Response will parse the reply message from SmugMug and detect if the stat was "ok" or "fail". If it was a "fail" stat, then the implementation will parse out the error code and message which you can retrieve using the getError().getCode() and getError().getMessage() methods respectively.
Also the existence of an error can be checked easily with
isError() on any response instance.
|
Invalid Login (Code 1)
|
Invalid Session (Code 3)Request:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.create&APIKey=<API
KEY>&SessionID=<ANONYMOUS SESSION
ID>&Title=<ALBUM TITLE>&CategoryID=<CATEGORY
ID>
Response:
{
|
Invalid User (Code 4)Request: http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.users.getTree&APIKey=<API KEY>&SessionID=<SESSION ID>&NickName=badNickName Response:
{
|
Invalid Sort Method (Code 12)Request:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.reSort&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>&By=INVALID_SORT_BY&Direction=<ASC or DESC>
Response:
{
|
Invalid Sort Direction (Code 13)Request:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.reSort&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>&By=<FileName, Caption or
DateTime>&Direction=INVALID_SORT_DIRECTION
Response:
{
|
Empty Set - No SubCategories Found (Code 15)Request:
[Any SubCategory get request that results in an empty reply]
Response:
{
|
Invalid Method (Code 17)Request:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.INVALID_METHOD
Response:
{
|
Invalid API Key (Code 18)
|
MethodsThe sections following will outline queries and responses from the SmugMug JSON API for the given method. Each method below has a corresponding class in the kallasoft SmugMug Java API in a package with the same naming structure contained under the com.kallasoft.smugmug.api.json.v1_2_0 parent package. For example, smugmug.login.anonymously is implemented by the class com.kallasoft.smugmug.api.json.v1_2_0.login.Anonymously and the reply from the server is modelled by the com.kallasoft.smugmug.api.json.v1_2_0.login.Anonymously.AnonymouslyResponse Response implementation. |
smugmug.login.anonymously
Request:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.login.anonymously&APIKey=<API KEY> Response:
{
|
smugmug.login.withPasswordRequest: https://api.smugmug.com/hack/json/1.2.0/?method=smugmug.login.withPassword&APIKey=<API KEY>&EmailAddress=<EMAIL ADDRESS>&Password=<PASSWORD> Response:
{
|
smugmug.login.withHashRequest:
https://api.smugmug.com/hack/json/1.2.0/?method=smugmug.login.withHash&APIKey=<API
KEY>&UserID=<USER ID>&PasswordHash=<PASSWORD
HASH>
Response:
{
|
smugmug.logoutRequest:
https://api.smugmug.com/hack/json/1.2.0/?method=smugmug.logout&APIKey=<API
KEY>&SessionID=<SESSION ID>
Response:
{
|
smugmug.users.getTreeRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.users.getTree&APIKey=<API
KEY>&SessionID=<SESSION ID>
Response: { Request (Heavy): http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.users.getTree&APIKey=<API KEY>&SessionID=<SESSION ID>&Heavy=1 Response (Heavy): { |
smugmug.users.getTransferStatsRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.users.getTransferStats&APIKey=<API
KEY>&SessionID=<SESSION ID>&Month=<MONTH,
1-12>&Year=<YEAR>
Response:
{
|
smugmug.albums.getRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.get&APIKey=<API
KEY>&SessionID=<SESSION ID>
Response:
{
Request (Heavy): http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.get&APIKey=<API KEY>&SessionID=<SESSION ID>&Heavy=1 Response (Heavy):
{
|
smugmug.albums.getInfoRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.getInfo&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>
Response:
{
Response (from a public album owned by another person):
{
|
smugmug.albums.createRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.create&APIKey=<API
KEY>&SessionID=<SESSION ID>&Title=<ENCODED
TITLE>&CategoryID=<CATEGORY ID>
Response:
{
|
smugmug.albums.changeSettingsRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.changeSettings&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>&Description=<ENCODED DESCRIPTION>
Response:
{
|
smugmug.albums.reSortRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.reSort&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>&By=<FileName, Caption or
DateTime>&Direction=<ASC or DESC>
Response:
{
|
smugmug.albums.deleteRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.delete&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>
Response:
{
|
smugmug.albums.getStatsRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albums.getStats&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>&Month=<MONTH, 1-12>&Year=<YEAR>
Response:
{
|
smugmug.albumtemplates.getRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.albumtemplates.get&APIKey=<API
KEY>&SessionID=<SESSION ID>
Response:
{
|
smugmug.images.getRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.get&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>
Response:
{
Request (Heavy): http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.get&APIKey=<API KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM ID>&Heavy=1 Response (Heavy): { |
smugmug.images.getURLsRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.getURLs&APIKey=<API
KEY>&SessionID=<SESSION ID>&ImageID=<IMAGE
ID>
Response:
{
|
smugmug.images.getInfoRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.getInfo&APIKey=BqPrphSt23shcGtMavNqiXChVYIINIBb&SessionID=e9bd0ccede7a46d1fa30ce8c178b9a19&ImageID=<IMAGE
ID>
Response:
{
|
smugmug.images.getEXIFRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.getEXIF&APIKey=<API
KEY>&SessionID=<SESSION ID>&ImageID=<IMAGE
ID>
Response:
{
|
smugmug.images.changeSettingsRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.changeSettings&APIKey=<API
KEY>&SessionID=<SESSION ID>&ImageID=<IMAGE
ID>&Caption=<CAPTION>&Keywords=<KEY WORDS,
SPACE DELIMITED>
Response:
{
|
smugmug.images.changePositionRequest: http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.changePosition&APIKey=<API KEY>&SessionID=<SESSION ID>&ImageID=<IMAGE ID>&Position=<POSITION> Response:
{
|
smugmug.images.uploadRequest:
http://upload.smugmug.com/hack/json/1.2.0/?method=smugmug.images.upload&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>&FileName=<FILE NAME>&Data=<BASE64 ENCODED
DATA>&ByteCount=<BYTE
COUNT>&MD5Sum=<MD5Sum>
Response:
{
|
smugmug.images.uploadFromURL
NOTE:
This method's usefulness has not been clarified by
SmugMug yet. In order to calculate the ByteCount and MD5Sum, you
would have to have downloaded the image. In which case you would
just use smugmug.images.upload
or a Binary Upload method.
Request:
http://upload.smugmug.com/hack/json/1.2.0/?method=smugmug.images.uploadFromURL&APIKey=<API
KEY>&SessionID=<SESSION ID>&AlbumID=<ALBUM
ID>&URL=<IMAGE
URL>&Keywords=<KEYWORDS>&Latitude=<LATITUDE>&Longitude=<LONGITUDE>&Altitude=<ALTITUDE,
in METERS>&ByteCount=<BYTE
COUNT>&MD5Sum=<MD5Sum>
Response:
{
|
Binary Upload: HTTP PutRequest: Please Refer to Binary Upload: HTTP Put documentation Response:
{
|
smugmug.images.deleteRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.delete&APIKey=<API
KEY>&SessionID=<SESSION ID>&ImageID=<IMAGE
ID>
Response:
{
|
smugmug.images.getStatsRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.images.getStats&APIKey=<API
KEY>&SessionID=<SESSION ID>&ImageID=<IMAGE
ID>&Month=<MONTH, 1-12)
Response:
{
|
smugmug.categories.getRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.categories.get&APIKey=<API
KEY>&SessionID=<SESSION ID>
Response:
{
|
smugmug.categories.createRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.categories.create&APIKey=<API
KEY>&SessionID=<SESSION ID>&Name=<CATEGORY
NAME>
Response:
{
|
smugmug.categories.deleteRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.categories.delete&APIKey=<API
KEY>&SessionID=<SESSION
ID>&CategoryID=<CATEGORY ID>
Response:
{
|
smugmug.categories.renameRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.categories.delete&APIKey=<API
KEY>&SessionID=<SESSION
ID>&CategoryID=<CATEGORY ID>&Name=<NEW
CATEGORY NAME>
Response:
{
|
smugmug.subcategories.getRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.subcategories.get&APIKey=<API
KEY>&SessionID=<SESSION
ID>&CategoryID=<PARENT CATEGORY ID>
Response:
{
|
smugmug.subcategories.getAllRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.subcategories.getAll&APIKey=<API
KEY>&SessionID=<SESSION ID>
Response:
{
|
smugmug.subcategories.createRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.subcategories.create&APIKey=<API
KEY>&SessionID=<SESSION ID>&Name=<SUB
CATEGORY NAME>&CategoryID=<PARENT CATEGORY ID>
Response:
{
|
smugmug.subcategories.deleteRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.subcategories.delete&APIKey=<API
KEY>&SessionID=<SESSION
ID>&SubCategoryID=<SUB CATEGORY ID>
Response:
{
|
smugmug.subcategories.renameRequest:
http://api.smugmug.com/hack/json/1.2.0/?method=smugmug.subcategories.rename&APIKey=<API
KEY>&SessionID=<SESSION
ID>&SubCategoryID=<SUB CATEGORY ID>&Name=<NEW
SUB CATEGORY NAME>
Response:
{
|