Account Management
Usage API
Track the billed requests of your account over a period, in total and per API key — without going through the Staan console. Combined with the API Keys API, it lets you bill your own customers for the searches they make with the keys you created for them.
Code
Data is available up to the previous day: the current day is not included.
Authentication
Call this endpoint with an API key created in the Staan console:
Code
Keys created through POST /v1/keys can only be used for search: on /v1/usage they get 403 SCOPE_NOT_GRANTED.
Quick start
Daily usage for October
Monthly usage of one key
Parameters
| Parameter | Required | Description |
|---|---|---|
from | yes | Start of the period, inclusive, YYYY-MM-DD |
to | yes | End of the period, inclusive, YYYY-MM-DD |
granularity | no | daily (default) or monthly |
key_id | no | Restrict the result to one key of your account |
The period cannot exceed 366 days, and from must be before or equal to to.
Response
Code
| Field | Description |
|---|---|
total | Usage of the whole account over the period (or of key_id only) |
keys[].key_id / keys[].name | Identifier and name of the key |
keys[].total | Usage of this key over the period |
keys[].usage[] | Usage of this key per day or per month |
date | YYYY-MM-DD in daily mode, YYYY-MM in monthly mode |
web_search | Billed Web Search requests |
web_search_for_ai | Billed Web Search for AI requests |
total | Sum of web_search and web_search_for_ai |
- Days or months without usage are omitted from
usage. - Deleted keys still count in
total, and are listed inkeysonly if they had usage in the period.
Rate limits and errors
This endpoint accepts 1 request per second, per key. Above that it returns 429: wait a second and retry.
| HTTP | code / message | Cause |
|---|---|---|
400 | from must be before or equal to to, The period cannot exceed 366 days, invalid parameter | Invalid parameters |
401 | INVALID_KEY_FORMAT | Missing or malformed Authorization header |
401 | INVALID_CREDENTIALS | Unknown key or wrong secret |
403 | KEY_DISABLED | The key is disabled |
403 | SCOPE_NOT_GRANTED | Key created through the API: use a console key |
404 | not found | key_id does not belong to your account |
410 | KEY_EXPIRED | The key has expired |
429 | too many requests | Rate limit exceeded |
Last modified on