API Formats - XML vs. JSON(P)
Our API supports sending responses in XML and JSON. In addition, we support JSONP, which is JSON wrapped in a custom JavaScript function call.
How you specify the format you want depends on whether you’re using the default RESTful variant or the non-RESTful variant of our API.
Specifying format the RESTful way
If you’re using the default RESTful variant of our API, you can specify
the format you want
content
objects in via the Accept request header. Set this header
to application/xml for XML or
application/json for JSON.
JSONP isn’t supported in the RESTful variant of our API.
If there is no Accept header, we default to JSON.
Note that in the RESTful variant of the API, error responses (signified
by a 4xx or 5xx status code) always have the response body in plaintext,
regardless of the format specified in the Accept header.
This response body is meant to be a human-readable error message.
Specifying format the non-RESTful way
If you want to use the non-RESTful variant of our API, you can specify
the format you want via the query string. Send a format=xml
parameter for XML or format=json for JSON. This will
override the Accept header if there is one and trigger the
non-RESTful API.
To specify JSONP, add a callback=<function> parameter
to the query string, where <function> is the name of
the JavaScript function to call with the response object.
In this case, the format=json parameter is not explicitly
required.
In the non-RESTful variant of the API, the response body will always be
a response
object, and it will always be in the format specified.
Side-by-side example - Content object
The following is an example
content object in the default JSON format:
{
"id": "11mb",
"url": "http://example.com/",
"ready": true,
"failed": false,
"progress": 1,
"shareUrl": "http://zoom.it/11mb",
"embedHtml": "<script src=\"http://zoom.it/11mb.js?width=auto&height=400px\"></script>",
"dzi": {
"url": "http://cache.zoom.it/content/11mb.dzi",
"width": 1024,
"height": 640,
"tileSize": 254,
"tileOverlap": 1,
"tileFormat": "png"
}
}
The same content object in XML format:
<content>
<id>11mb</id>
<url>http://example.com/</url>
<ready>true</ready>
<failed>false</failed>
<progress>1</progress>
<shareUrl>http://zoom.it/11mb</shareUrl>
<embedHtml><script src="http://zoom.it/11mb.js?width=auto&height=400px"></script></embedHtml>
<dzi>
<url>http://cache.zoom.it/content/11mb.dzi</url>
<width>1024</width>
<height>640</height>
<tileSize>254</tileSize>
<tileOverlap>1</tileOverlap>
<tileFormat>png</tileFormat>
</dzi>
</content>
Side-by-side example - Response object
The following is an example
response object in the default JSON format:
{
"status": 301,
"statusText": "Moved Permanently",
"redirectLocation": "http://api.zoom.it/v1/content/11mb",
"content": {
"id": "11mb",
"url": "http://example.com/",
"ready": true,
"failed": false,
"progress": 1,
"shareUrl": "http://zoom.it/11mb",
"embedHtml": "<script src=\"http://zoom.it/11mb.js?width=auto&height=400px\"></script>",
"dzi": {
"url": "http://cache.zoom.it/content/11mb.dzi",
"width": 1024,
"height": 640,
"tileSize": 254,
"tileOverlap": 1,
"tileFormat": "png"
}
}
}
The same response object in XML format:
<response>
<status>301</status>
<statusText>Moved Permanently</statusText>
<redirectLocation>http://api.zoom.it/v1/content/11mb</redirectLocation>
<content>
<id>11mb</id>
<url>http://example.com/</url>
<ready>true</ready>
<failed>false</failed>
<progress>1</progress>
<shareUrl>http://zoom.it/11mb</shareUrl>
<embedHtml><script src="http://zoom.it/11mb.js?width=auto&height=400px"></script></embedHtml>
<dzi>
<url>http://cache.zoom.it/content/11mb.dzi</url>
<width>1024</width>
<height>640</height>
<tileSize>254</tileSize>
<tileOverlap>1</tileOverlap>
<tileFormat>png</tileFormat>
</dzi>
</content>
</response>
