AboutContactLogin

Index

Working with JSON-RPC

JSON-RPC is a light-weight remote procedure call protocol that uses JavaScript Object Notation (JSON) as the data format for requests and responses. You can find more details on this protocol in the JSON-RPC Specification.

Below is an example of a JSON-RPC request and response (in this case, for the LoadPhoto method):

POST /api/1.8/zfapi.asmx HTTP/1.1<cr><lf>
Host: api.zenfolio.com<cr><lf>
User-Agent: Acme PhotoEdit plugin for Zenfolio<cr><lf>
Content-Type: application/json<cr><lf>
Content-Length: 75<cr><lf>
<cr><lf>
{
  "method": "LoadPhoto",
  "params": [327977501],
  "id": 1
}

HTTP/1.1 200 OK<cr><lf>
Content-Type: application/json; charset=UTF-8<cr><lf>
Content-Length: 938<cr><lf>
<cr><lf>
{
  "id": 1,
  "error": null,
  "result": {
    "$type": "Photo",
    "Id": 327977501,
    "Width": 878,
    "Height": 598,
    "Sequence": "",
    "Title": "Racoon",
    "Keywords": [
    ],
    "Categories": [
      1018000,
      1000000
    ],
    "Gallery": 492530544,
    "Size": 482933,
    "FileName": "14.jpg",
    "MimeType": "image/jpeg",
    "UploadedOn": {
      "$type": "DateTime"
      "Value": "2006-16-28 08:16:42",
    },
    "TakenOn": {
      "$type": "DateTime"
      "Value": "2006-16-28 12:16:42",
    },
    "Views": 0,
    "OriginalUrl": "/img/v0/p327977501.jpg",
    "UrlCore": "/img/v0/p327977501",
    "AccessDescriptor": {
      "$type": "AccessDescriptor",
      "RealmId": 180436196,
      "IsDerived": false,
      "AccessMask": "ProtectOriginals, ProtectExtraLarge",
      "AccessType": "Public"
    },
    "IsCensored": false
  }
}

Several important points to keep in mind:

  • The HTTP method must be POST, and the Content-Type header must be set to "application/json".
  • The JSON data format does not define a way to indicate the type of transmitted objects. To help your application identify object types, every object returned by the Zenfolio API has a property called "$type" that indicates the object type.
  • Dates are returned as objects with "$type" property set to "DateTime". The only other property of a date object is the "Value" property which represents the date in the following format: "yyyy-MM-dd hh:mm:ss". All times are UTC unless noted otherwise in the corresponding field description.
  • Enumeration constants are returned as string literals corresponding to symbolic constant names. Values for flag-type enumerations (enumerations that allow their values to combine several constants) are returned as comma-separated lists of corresponding constants (see "AccessMask" property in the above example).