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 (UTC). 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 must contain valid JSON (as described in RFC4627). The Content-Type must either be absent or set to application/json, or a MalformedJSON (400) error occurs. Query parameters in the URL are ignored.
An optional header "DNAnexus-API" can also be provided to indicate which version of the API to use. The DNAnexus API reference describes the API with version string "1.0.0". If the header is not given, the most recent version is used.
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.
If a POST request to the URL of an API method includes the "Origin" header, its contents are 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) are accepted if the value of the "Access-Control-Request-Method" header is "POST". The values of "Origin" and "Access-Control-Request-Headers" (if any) are 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" is also provided with a 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". The value of "type" is a string with a DNAnexus-defined error type, and the message contains a short description of the error in English.
MalformedJSON
The input cannot be parsed as JSON.
400
InvalidAuthentication
The provided OAuth2 token is invalid.
401
PermissionDenied
Insufficient permissions to perform this action.
401
SpendingLimitExceeded
The spending limit has been reached for the account that is billed for this action.
403
OrgExpired
The organization has expired and can no longer perform billable operations.
403
ResourceNotFound
A specified entity or resource could not be found.
404
InvalidInput
The input is syntactically correct (JSON), but semantically incorrect. This can occur when a JSON array is provided where a hash was required, when a required parameter is missing, or when parameter formats don't match expected types.
422
InvalidState
The operation is not allowed in this object state.
422
InvalidType
An object specified in the request is of invalid type.
422
RateLimitConditional
Too many invalid requests.
429
InternalError
The server encountered an internal error.
500
ServiceUnavailable
Some service was temporarily unavailable.
503
Some errors may also provide additional details in the details field. The documentation for the API method describes when such detailed information appears and what subfields to expect. An example of such an error occurs 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 can be retried. For example, you can retry any 5xx response code (up to some limit). For more information, see the HTTP retry section in the dx-toolkit documentation.
Last updated
Was this helpful?