Protocols
Encoding
All API calls are made over HTTPS, receive JSON input, and return JSON output. For information about what JSON is, refer to RFC 4627 and JSON (Wikipedia).
Any timestamps that appear in the response from or as input for an API method are always given as numbers signifying the millisecond count since the Unix Epoch. For example, "Tue, 31 Jan 2012 00:02:30 GMT" is represented as the number 1327968150000.
Input
Each API method has a distinct corresponding URL. Calls to this URL are made with HTTP POST. The body of the message is expected to contain valid JSON (as described in RFC4627). The Content-Type must either be absent or set to application/json
, or a MalformedJSON (400) error will be issued. Query parameters in the URL are ignored.
An optional header "DNAnexus-API" may also be provided to indicate which version of the API should be used. This document describes the API with version string "1.0.0". If the header is not given, it is assumed that the most recent version should be used.
NOTE: Certain API methods do not require any input. However, for compatibility with the future, JSON parsing will still be performed, so valid JSON must still be provided in the body, but that JSON will only be checked syntactically, not semantically.
CORS Support
All URLs corresponding to API methods have some support for CORS (cross-origin resource sharing), based on the 27 July 2010 W3C Working Draft. More specifically:
If a POST request to the URL of an API method includes the "Origin" header, its contents will be propagated into the "Access-Control-Allow-Origin" header of the response.
Preflight requests (OPTIONS requests to the URL of an API method, with appropriate extra headers as defined in the CORS draft) will be accepted if the value of the "Access-Control-Request-Method" header is "POST". The values of "Origin" and "Access-Control-Request-Headers" (if any) of the request, will be propagated to "Access-Control-Allow-Origin" and "Access-Control-Allow-Headers" respectively in the response. The "Access-Control-Max-Age" of the response is set to 1 year.
Output
Successful results are always returned as JSON in the response body, with response code 200. All responses are UTF-8 encoded. A header called "DNAnexus-API" will also be provided with value equal to the version number of the API used to fulfill the query.
Errors
Non-successful invocations of the API return an error. Errors are represented with an HTTP error code, and the response body contains a JSON object with the following structure:
The object contains a single key, "error". Its value is an object with two keys, "type" and "message". They value of "type" is a string with a DNAnexus-defined error type, and the message contains a short description of the error in English.
Some errors may also choose to provide additional details in another field called "details". The documentation for the route will describe when such detailed information will be provided and what subfields can be expected. An example of such an error is after attempting to run an applet with invalid input for one of the applet’s input fields:
Errors in Execution Environments
For more information about how errors are propagated during app and applet execution, see the Execution Environment page.
Request retries
Each request receives an HTTP response code from the server. Some responses indicate that the request should be retried. For example, any 5xx response code should be retried (up to some limit). For more information, see the HTTP retry section in the client documentation.
Last updated