API key

Statistics

Fetch dashboard statistics for all time or a selected reporting scope.

GET
/v1/stats
API key scope stats:read - Fetch user statistics with an optional scope query parameter.
GET
/v1/stats/:scope
API key scope stats:read - Fetch user statistics for a scope supplied in the path.

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

FieldRequiredNotes
scopeNoOne of 24h, 1w, 1month, 1year, or all. Defaults to 1month.

Path parameters

FieldRequiredNotes
scopeYesSame 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

FieldNotes
total_messagesAll-time count for the authenticated user.
scoped_messagesMessage count inside the selected scope.
scoped_increase_percentPercentage change against the previous matching scope. all returns 0.
success_rate_percentPercentage of scoped messages with sent or delivered status.
otp_verification_success_rate_percentPercentage of scoped OTP sessions that were verified.
charts.scopeNormalized scope used by the backend.
charts.messagesMessage series for the selected scope.
charts.otpsOTP session series for the selected scope.
charts.campaignsMarketing audience message series for the selected scope.
charts.operatorsOperator totals for ooredoo, mobilis, and djeezy.