API Documentation
Instructions for using Crocodoc in your own applications
A newer version of Crocodoc's API is now available. Go to https://crocodoc.com/docs/ to view the documentation for our new API.
Authentication
All API requests require use of a valid API token. The following request uses an example API token to delete an uploaded document:
https://personal.crocodoc.com/api/v1/document/delete?uuid=a7f1fbb0-24d2-11df-8a39-0800200c9a66&token=
API Methods
/api/v1/document/upload?
Upload and convert a file. This method will try to convert a file that has been referenced by a URL or has been uploaded via a POST request.
Example request: https://personal.crocodoc.com/api/v1/document/upload?url=http://www.dcaa.mil/chap6.pdf&token=
Crocodoc's free API has a rate limit of two simutaneous conversions.
To have rate limiting removed, contact support@crocodoc.com.
Arguments
-
&url={URL}
Required if no file is uploaded. Location of the file to be fetched and converted.
-
&file={uploaded file}
Required if no url is provided. File should be uploaded using a multipart POST request (detail below).
-
&title={title}
(optional) title of the document
-
&async={boolean}
(optional) When in async mode, a response is returned before conversion begins. default:false
-
&private={boolean}
(optional) private documents can only be accessed by owners or via sessions. default:false
-
&token={API token}
(required)
Example Response
Results are returned using JSON syntax. If the request was successful:
{"shortId": "yQZpPm", "uuid": "8e5b0721-26c4-11df-b354-002170de47d3"}
If an error occurred:
{"error": "conversion error"}
The following errors may occur: invalid params, invalid token, invalid url, invalid filetype,
password protected, rate limited, conversion error, and error.
Uploading via POST
The following unix command uploads a file to Crocodoc via a multipart POST request. To submit POST requests using Python, it is recommended that you use this code
snippet. For PHP, please view this example.
For help with multipart POST requests in other languages, feel free to contact support@crocodoc.com.
curl -F "file=@example.pdf" -F "token={API token}" -F "title=Example PDF" https://personal.crocodoc.com/api/v1/document/upload
/api/v1/document/status?
Check the conversion status of a document.
Arguments
Example Request
https://personal.crocodoc.com/api/v1/document/status?uuids=8e5b0721-26c4-11df-b354-002170de47d3,b54adc00-67f9-11d9-9669-0800200c9a66&token=
Example Response
[{"uuid": "8e5b0721-26c4-11df-b354-002170de47d3", status: "QUEUED", viewable: false},
{"uuid": "b54adc00-67f9-11d9-9669-0800200c9a66", status: "AVAILABLE", viewable: true}]
The following document statuses may be returned: "QUEUED", "CONVERTING", "AVAILABLE", "ERROR".
Crocodoc allows users to view partially converted documents. Even if a document's status is "CONVERTING", a document is viewable as soon as the "viewable" flag is true.
Web Hooks
Web hooks are available for high-volume API users. Web hooks allow us to notify your servers as soon as a document's conversion status changes.
Email support@crocodoc.com for more information.
/api/v1/document/delete?
Delete an uploaded file.
Arguments
Example Response
If the request was successful:
true
If an error occurred:
{"error": "invalid uuid"}
/api/v1/document/download?
Download an uploaded file with or without annotations.
Arguments
Example Use
wget "https://personal.crocodoc.com/api/v1/document/download?uuid=08a7c925-e137-44ab-ab2d-ebe62edfaec8&token="
/api/v1/document/share?
Creates a new "short ID" that can be used to share a document.
Arguments
Example Response
{"shortId": "y1O7rK" }
/api/v1/document/clone?
Clones an uploaded document. Document annotations are not copied.
Arguments
Example Response
{"shortId": "yQZpPm", "uuid": "8e5b0721-26c4-11df-b354-002170de47d3"}
/api/v1/session/get?
Creates a session ID for session-based document viewing. Each session ID may only be used once.
The following URL uses an example session ID to grant access to a private document:
https://personal.crocodoc.com/view/?sessionId=fgH9qWEwnsJUeB0.
Example request
https://personal.crocodoc.com/api/v1/session/get?uuid=8e5b0721-26c4-11df-b354-002170de47d3&editable=false&token=
Arguments
-
&uuid={uuid}
(required) uuid of the document to be viewed
-
&token={API token}
(required)
-
&downloadable={boolean}
(optional) enables document downloads. default: true
-
&editable={boolean}
(optional) Can users markup the document? default: true
-
&name={name}
(optional) name of the person viewing the document.
-
&admin={boolean}
(optional) Admins can delete any user's annotations. default: false
Example Response
{"sessionId": "fgH9qWEwnsJUeB0" }
http://personal.crocodoc.com/{shortId}?embedded=true
View an embedded document. This URL returns a web page that can be embedded within an iframe.
Example Document
The following iframe is set to this URL:
http://personal.crocodoc.com/demo?embedded=true
Tip: Add the following CSS rule to show a spinner while the iframe loads.
iframe { background:url(//personal.crocodoc.com/media/images/docviewer/spinner.gif) no-repeat center; }
https://personal.crocodoc.com/view/?sessionId={sessionId}
View a document using session-based viewing.
Session-based viewing enables the embedding of private documents.
To obtain session IDs, use the session/get API method.
Example Session
http://personal.crocodoc.com/view/?sessionId=fgH9qWEwnsJUeB0
Arguments
Arguments should be passed in when creating session IDs.