Quick Start
Requests & Responses
The API follows familiar RESTful conventions for requests, responses and errors
- Fetching resources is done using
GET
requests.- Query parameters can be used to filter, sort and paginate the results.
- Creating resources using
POST
requests. PUT
,PATCH
andDELETE
requests aren't currently used.
Responses
- All responses are returned in
application/json
format. - Errors are mostly communicated using HTTP status codes with a JSON body.
- Successful responses will be 200, 201 or 204 (if there resource to return).
Collections
- Endpoints that return a collection of resources will return a JSON object with a
<resources>
field that contains an array of resource objects.- For devices, the resource is
devices
, for sites, the resource issites
, etc.
- For devices, the resource is
- The response will include a
total
field that contains the total number of resources in the collection (not the number of resources returned in the response).- The
total
field is represented the total number of resources that match filters, not the total number of resources in the database.
- The
For example, fetching devices
will return the following structure:
{ "devices": [ { "id": "1", ... }, { "id": "2", ... } ], "total": 3 }json
Errors
Common error status codes are:
Code | Description |
---|---|
400 | Invalid/Bad Request |
401 | No/Invalid Credentials Or Expired JWT Token |
403 | No Permissions To Access the Resource |
429 | Rate Limit Exceeded |
500 | Internal Server Error |
We do not return a body with error status codes, currently the status code is sufficient to identify the error.
Once mutation endpoints are added, we will return a JSON body with an error message.
{ "error": "Bad request", "message": "Site name must be unique" }json
Endpoints can return multiple messages in the message
field.
{ "error": "Bad request", "message": ["Site name must be unique", "Site name must be at least 3 characters long"] }json