Overview
The Statistics API returns the authenticated API key owner's dashboard metrics and chart series. Use an API key with the stats:read scope.
The default scope is 1month. Supported scopes are 24h, 1w, 1month, 1year, and all.
Fetch statistics
curl https://api.bar9.me/v1/stats?scope=1w \
-H "Authorization: Bearer $BAR9_API_KEY"You can also pass the scope in the path:
curl https://api.bar9.me/v1/stats/all \
-H "Authorization: Bearer $BAR9_API_KEY"Query parameters
| Field | Required | Notes |
|---|---|---|
scope | No | One of 24h, 1w, 1month, 1year, or all. Defaults to 1month. |
Path parameters
| Field | Required | Notes |
|---|---|---|
scope | Yes | Same values as the query parameter scope list. |
Response
{
"ok": true,
"data": {
"total_messages": 1280,
"scoped_messages": 143,
"scoped_increase_percent": 12.5,
"success_rate_percent": 96.8,
"otp_verification_success_rate_percent": 82.3,
"credit_balance": 4200,
"charts": {
"scope": "1w",
"labels": ["Jun 04", "Jun 05"],
"messages": [{ "bucket": 1780531200, "label": "Jun 04", "total": 41 }],
"otps": [{ "bucket": 1780531200, "label": "Jun 04", "total": 12 }],
"campaigns": [{ "bucket": 1780531200, "label": "Jun 04", "total": 4 }],
"operators": [
{ "operator": "ooredoo", "total": 63 },
{ "operator": "mobilis", "total": 51 },
{ "operator": "djeezy", "total": 29 }
]
},
"recent_activity": []
}
}Response fields
| Field | Notes |
|---|---|
total_messages | All-time count for the authenticated user. |
scoped_messages | Message count inside the selected scope. |
scoped_increase_percent | Percentage change against the previous matching scope. all returns 0. |
success_rate_percent | Percentage of scoped messages with sent or delivered status. |
otp_verification_success_rate_percent | Percentage of scoped OTP sessions that were verified. |
charts.scope | Normalized scope used by the backend. |
charts.messages | Message series for the selected scope. |
charts.otps | OTP session series for the selected scope. |
charts.campaigns | Marketing audience message series for the selected scope. |
charts.operators | Operator totals for ooredoo, mobilis, and djeezy. |