Metrics API
Octodash's Metrics API enables developers to track and manage metrics.
The API supports creating a Metrics Action, that can increment or decrement the metric value.
Each metric action can optionally be associated with a specific user, denoting responsibility for that action.
Retrieving all metrics from a website
GET https://octodash.app/api/v1/metric/{siteId}
Header
| Field | Type | Description |
|---|---|---|
X-API-KEY | string | Your API Key. |
Responses
200.
[{
"id": number,
"siteId": string,
"value": number, // Current Metric Value
"name": string
}...]
403 X-API-KEY error, missing or invalid key.
404 Invalid Website. The siteId does not exist.
Creating a metrics action
POST https://octodash.app/api/v1/metric/{siteId}/{metricId}
Header
| Field | Type | Description |
|---|---|---|
X-API-KEY | string | Your API Key. |
Body
| Field | Type | Description |
|---|---|---|
value | number | Value that will increase/decrease the metric total value. This value can be positive to increase, or negative do decrease. |
visitor | string (optional) | The user visitor ID to associate with this action. |
The user visitor ID can be retrieved from the cookie octoSession.
This cookie is used by OctoDash to keep track of the current user session and it's automatically added into your website when you use our <script> src.
Responses
403 X-API-KEY error, missing or invalid key.
404 Invalid Metric. The metricId does not exist, or it's not assigned to the siteId
404 Visitor Not Found. The visitor does not exist, or it's not assigned to the current siteId