24Metrics API Documentation (1)
The API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
All requests to the API must be authenticated using an API key. To authenticate, add a API-KEY header to your request that contains your API Key.
- For network administrators you can create individual API keys and find your API keys under Organization > API Access.
- For all users you can use your own API key by going to Profile > Security > Enable API Access.
| Code | Summary | Description |
|---|---|---|
| 200 | OK | Everything worked as expected. |
| 400 | Bad Request | The request was unacceptable, often due to missing a required parameter. |
| 401 | Unauthorized | No valid API key provided. |
| 402 | Request Failed | The parameters were valid but the request failed. |
| 403 | Forbidden | The API key doesn't have permissions to perform the request. |
| 404 | Not Found | The requested resource doesn't exist. |
| 429 | Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
| 500, 502, 503, 504 | Server Errors | Something went wrong on Server's end. (These are rare.) |
We use conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a wrong data type is provided to a json field). Codes in the 5xx range indicate an error with our servers (these are rare).
To filter the result you can use the filter query parameter. Format:
filter[field_name][operator] = value
- field_name - is the field or property name. To filter a property within an object use dots such as
filter[outer_field.inner_field] - operator - the operators used. If omitted, the default operator is
eq.
You can sort the result by adding sort query params like sort=-type,name. - will act for descending
The API in general is using numbered pages except for Reports.
To paginate the result you can provide the following:
page[number]is the number of the page.page[size]is the size of the page. The API max limit is 100.
In the response, meta.total_count shows the number of total objects and meta.total_page shows the number of total pages.
{
"meta": {
"total_count": 1000,
"total_page": 50
}
}
Example:
Go to the first page:
GET /api/v2/coffees?page[size]=100&page[number]=1
Go to the second page:
GET /api/v2/coffees?page[size]=100&page[number]=2
Supported parameters vary by endpoint; use the parameters documented on each operation. For page-based lists, page[number] is one-based and page[size] limits results; meta.total_count is the matching total before pagination. Cursor parameters page[after] and page[before] are only supported on endpoints that use cursor pagination; they are ignored on others and cannot be combined.
Where supported, query searches the fields named on the operation. sort accepts comma-separated field names; prefix a field with - for descending order. Endpoint-specific sort restrictions take precedence.
Generic filters use filter[field][operator]=value. Operators include eq (the default, including true/false booleans), ne, match (case-insensitive substring), eq_n/ne_n (numeric equality/inequality), gt/gte/lt/lte (numeric comparisons), eq_date/ne_date/gt_date/gte_date/lt_date/lte_date (YYYY-MM-DD dates), gt_id/gte_id/lt_id/lte_id (ID comparisons), and exists/is_empty/is_not_empty (true/false). Available fields and operators depend on the endpoint and storage type.
For string eq/ne/match and numeric eq_n/ne_n/gt/gte/lt/lte filters, repeat the parameter with one value per occurrence or supply a comma-separated list in a single occurrence; do not mix these forms. For these operators, filter[field][operator][and] or [or] combines values using all/any semantics (default: and). filter[field][and] and filter[field][or] are shorthand for string equality. Date operators, ID-comparison operators, boolean eq, and exists/is_empty/is_not_empty take a single value; repeated parameters use only the first value, and comma-separated lists are not supported for these forms.