Rank customers by completed invoice revenue in a single currency. Use this report for your Telegram subscription bot or Discord subscription bot project.
GET /v2/projects/ {project_id} /analytics/leaderboard CopyTry it Authorization Bearer API Key Required
API key scope: analytics:charts:read for restricted keys. Unrestricted project keys also support this endpoint.
Query Parameters First UTC calendar day, YYYY-MM-DD; default to minus 29 days.
Last UTC calendar day inclusive, YYYY-MM-DD; default today.
Optional 3–9 letters or digits, any case; default currency with most sales.
Digits-only integer from 1 to 100; default 10.
Dates must be real calendar days between 2000-01-01 and 2099-12-31, with from no later than to and at most 366 days inclusive. Unknown query parameters are rejected. There is no request body. See the shared analytics date, money, and cache rules .
Rows sort by revenue descending, then payment count, with stable user-ID ordering for ties. Totals cover all customers in the window, beyond the returned limit. Restricted keys receive ranks without user_id; unrestricted keys can receive identifiers. Even an anonymous rank reveals one customer's spend. Without a currency query, choose the currency with most sales, breaking ties alphabetically; an empty window then returns currency null.
curl "https://api.botsubscription.com/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard?from=2026-10-01&to=2026-10-31¤cy=USD&limit=2" \
-H "Authorization: Bearer YOUR_API_KEY" Report with unrestricted project key application/json
{
"ok" : true ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 200 ,
"data" : {
"period" : {
"from" : "2026-10-01" ,
"to" : "2026-10-31" ,
"interval" : null ,
"timezone" : "UTC" ,
"generated_at" : "2026-11-01T12:00:00.000Z"
},
"currency" : "USD" ,
"entries" : [
{
"rank" : 1 ,
"user_id" : "810000000000000001" ,
"payments" : 2 ,
"revenue" : "20"
},
{
"rank" : 2 ,
"user_id" : "810000000000000002" ,
"payments" : 1 ,
"revenue" : "20"
}
],
"totals" : {
"customers" : 4 ,
"payments" : 7 ,
"revenue" : "50.2"
},
"disclosures" : {
"cache_ttl_seconds" : 120 ,
"timezone" : "UTC" ,
"currency_conversion" : false ,
"timestamp_anchor" : "settled_at_or_created_at" ,
"source" : "completed_invoice_payment_requests" ,
"customer_identifiers_included" : true ,
"singleton_groups_possible" : true ,
"rank_order" : "revenue_desc_payments_desc" ,
"max_entries" : 100 ,
"excluded_other_currencies" : {
"eur" : 1
}
}
}
} Restricted key with redacted fields application/json
{
"ok" : true ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 200 ,
"data" : {
"period" : {
"from" : "2026-10-01" ,
"to" : "2026-10-31" ,
"interval" : null ,
"timezone" : "UTC" ,
"generated_at" : "2026-11-01T12:00:00.000Z"
},
"currency" : "USD" ,
"entries" : [
{
"rank" : 1 ,
"payments" : 2 ,
"revenue" : "20"
},
{
"rank" : 2 ,
"payments" : 1 ,
"revenue" : "20"
}
],
"totals" : {
"customers" : 4 ,
"payments" : 7 ,
"revenue" : "50.2"
},
"disclosures" : {
"cache_ttl_seconds" : 120 ,
"timezone" : "UTC" ,
"currency_conversion" : false ,
"timestamp_anchor" : "settled_at_or_created_at" ,
"source" : "completed_invoice_payment_requests" ,
"customer_identifiers_included" : false ,
"singleton_groups_possible" : true ,
"rank_order" : "revenue_desc_payments_desc" ,
"max_entries" : 100 ,
"excluded_other_currencies" : {
"eur" : 1
}
}
}
} UNAUTHORIZED application/json
{
"ok" : false ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 401 ,
"error" : {
"error_code" : "UNAUTHORIZED" ,
"message" : "Invalid or expired authentication token."
}
} FORBIDDEN application/json
{
"ok" : false ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 403 ,
"error" : {
"error_code" : "FORBIDDEN" ,
"message" : "Access is not permitted."
}
} VALIDATION_ERROR application/json
{
"ok" : false ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 422 ,
"error" : {
"error_code" : "VALIDATION_ERROR" ,
"message" : "Invalid request parameters."
}
} EXPORT_LIMIT_EXCEEDED application/json
{
"ok" : false ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 413 ,
"error" : {
"error_code" : "EXPORT_LIMIT_EXCEEDED" ,
"message" : "The requested window exceeds the report limit."
}
} TOO_MANY_REQUESTS application/json
{
"ok" : false ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 429 ,
"error" : {
"error_code" : "TOO_MANY_REQUESTS" ,
"message" : "Too many requests. Please try again later."
}
} Invalid calendar day application/json
{
"ok" : false ,
"request_id" : "44444444-4444-4444-8444-444444444444" ,
"method" : "GET" ,
"path" : "/v2/projects/11111111-1111-4111-8111-111111111111/analytics/leaderboard" ,
"code" : 422 ,
"errors" : [
{
"message" : "query: from Not a valid calendar date." ,
"error_code" : "VALIDATION_ERROR"
}
]
} Use the project API authentication reference for API-key setup.