Skip to content

Response format

Ali Anwar edited this page Jun 15, 2017 · 2 revisions

The API response format consists of an http status and a JSON response body

http status

The following are the http status that the API returns, and need to be checked by the client.

200 Successful HTTP requests

400 Bad request, the server cannot process the request due to an error

401 Unauthorized request (need the client id)

404 The requested resource could not be found (URL errors)

500 Internal Server Error - This could be hardware or software problem on the server

JSON body format

{
    "results": [],
    "lookups": {},
    "errors": [],
    "success": true,
    "params": "/api/overview?iso3=afg&ci=000",
    "total": 0,
    "limit": 0,
    "offset": 0
}

results an array contains the desired data

lookups any related data that is required by request

errors error massages (usually technical - make sure to send to the database developer)

success status of the request true or false

params The request URL received by the server (for debugging purposes)

total The total amount of records found by the query, not the number of records returned

limit number of requested records in one request

offset start offset of the records

total, limit and offset are information used to paginate through the data, and it should only be used by Javascript functions that calls the endpoint.

The response my return success: true yet the results is empty, this mean that the query was successful, but no results were found.

Clone this wiki locally