Skip to main content

3.2 Synchronous Responses Format

Contents:

3.2.1 HTTP persistent connections

MollyBet API tries to return the appropriate HTTP status codes. These are only intended to be a general hint about the nature of the response being received; more details are contained within the response.
CodeMeaningDescription
200OKSuccess!
400Bad requestThe request was invalid. It contained badly formatted data, or data that fails validation. For example: a required parameter is missing, or an order is placed with a negative price.
401UnauthorisedAuthentication credentials were missing from the request or incorrect. You need to re-authenticate and try again.
403ForbiddenThe request has been denied due to the current user not having sufficient permissions to perform the requested action.
404Not foundThe requested URI cannot be found on the server. This may refer to the specific URL, or to the resource being identified (e.g. a specific betslip).
405Method not allowedThe given URI does not support this HTTP method (e.g. it supports GET, but you are trying to POST).
406Not acceptableThe response format requested by the Accept HTTP header is not supported by the API.
415Unsupported media typeThe request is in a format specified by the Content-Type HTTP header that the API does not support.
429Too many requestsYou are being rate limited.
500Internal Server ErrorAn unexpected error has occurred.
503Service UnavailableMollyBet API is unavailable or is being restarted.

3.2.2 Envelope

MollyBet API responses are wrapped in an envelope with a standard set of keys you can examine. A successful response will look like the following:
{
"status": "ok",
"data": "... some call-specific data here"
}

The status field will report ok for successful responses, or error when something has gone wrong. In addition to the status field, a successful response will always include a data field with the payload of the response.

Similarly for error responses, apart from the status field, they always contain a code field which corresponds to the name of the "exception" being raised. This is a machine- and human-readable string that describes the exact causes of the error encountered.

Furthermore, an error response may optionally contain a data field with a human-readable message giving more information about the error and how it may be resolved. For example, a 400 response to login could look like this:

{
"status": "error",
"code": "validation_error",
"data": {
"password": [
"This field is required."
]
}
}

3.2.3 Rate Limits

MollyBet API implements a rate limit policy to prevent abuse and ensure fair service to all the users of the service. The limits are generous and should not get in the way of regular use of our platform: they are mostly intended to prevent malicious use of the API and to guard against buggy programs. If you encounter HTTP response code 429 (Too many requests) during regular API usage please let us know.