API Quickstarts - HTTP
Because our API is RESTful by default, it’s easy to use on any platform that supports HTTP. To illustrate, the examples below use the popular, cross-platform command-line tool cURL.
To convert your content (image, webpage, PDF, SVG, ...) to a Deep Zoom
Image, just make an HTTP GET request to
http://api.zoom.it/v1/content/?url=<url>
where <url> is your content’s URL.
Be sure the URL starts with http:// or https://, and be sure to
URL-encode any special characters inside it.
The API will respond with a 301 Moved Permanently if we
successfully parsed your URL (the redirect will point to a permanent
endpoint for your content, which will make subsequent requests faster),
and the response body will be your content info (represented as a
content object)
in XML or JSON format.
You can specify whether you want XML or JSON by sending an
Accept request header set to
application/xml or application/json.
If you don’t specify, we’ll default to JSON.
curl -i -H "Accept: application/json" api.zoom.it/v1/content/?url=http://example.com/
HTTP/1.1 301 Moved Permanently
Location: http://api.zoom.it/v1/content/11mb
Content-Type: application/json
{
"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"
}
}
Parsing the content info is as easy as checking if the ready
field is set to true. If it is, your DZI is ready, and you
can get its info via the
dzi field.
If the DZI isn’t yet ready, check the failed field to see
if we had a problem. Otherwise, the progress field tells
you how far along our conversion is, between 0 and 1. You may choose to
keep polling until either ready or failed
become true.
If you just want the Zoom.it short URL for your content or the HTML snippet for the embeddable viewer, you can grab those at any time; they'll work even if the DZI isn’t ready.
All of this assumes that we accepted the URL you gave us. If we have trouble parsing your URL, or if our service is down for maintenance or overloaded, the API will respond with a 400 Bad Request or 503 Service Unavailable, respectively. In this case, the response body will be a plaintext human-readable error message.
curl -i -H "Accept: application/xml" api.zoom.it/v1/content/?url=example.com
HTTP/1.1 400 Bad Request
Content-Type: text/plain
Please give us the full URL, including the "http://" or "https://".
You can use those error messages to debug the problem during development. Don't rely on them programmatically, though, as they may change!
Thanks to the beauty of REST and the widespread support of HTTP, that's all there is to it.
