Get API Call Volume Statistics
Through this interface, you can obtain aggregated statistics of call volumes grouped by date and API, suitable for generating usage reports, cost analysis, and other scenarios.
This interface requires authentication, for details please refer to Platform Token.
¶ Interface Description
- Request Method: GET
- Request URL:
https://platform.acedata.cloud/api/v1/usage/apis/aggregate/ - Request Headers:
- accept:
application/json - authorization:
Bearer {token}
- accept:
¶ Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
application_id |
string | No | Filter by application ID |
api_id |
string | No | Filter by API ID, supports multiple |
created_at_from |
string | No | Start date for statistics (ISO 8601 format) |
created_at_to |
string | No | End date for statistics (ISO 8601 format) |
¶ CURL Request Example
curl -X GET \
-H "accept: application/json" \
-H "authorization: Bearer {token}" \
"https://platform.acedata.cloud/api/v1/usage/apis/aggregate/"
Statistics by time range:
curl -X GET \
-H "accept: application/json" \
-H "authorization: Bearer {token}" \
"https://platform.acedata.cloud/api/v1/usage/apis/aggregate/?created_at_from=2024-08-01T00:00:00Z&created_at_to=2024-08-31T23:59:59Z"
¶ Example of Returned Results
{
"results": [
{
"date": "2024-08-15",
"api_id": "api-uuid-1",
"amount": 45.5
},
{
"date": "2024-08-15",
"api_id": "api-uuid-2",
"amount": 12.3
},
{
"date": "2024-08-16",
"api_id": "api-uuid-1",
"amount": 30.2
}
],
"total": 88.0,
"api_map": {
"api-uuid-1": {
"name": "Midjourney Imagine",
"path": "/v1/midjourney/imagine"
},
"api-uuid-2": {
"name": "Claude Messages",
"path": "/v1/claude/messages"
}
}
}
¶ Explanation of Returned Fields
| Field | Type | Description |
|---|---|---|
results |
array | Aggregated data for each API per day |
results[].date |
string | Date (YYYY-MM-DD format) |
results[].api_id |
string | API ID |
results[].amount |
number | Total consumption amount for the API on that day |
total |
number | Total consumption amount for all records |
api_map |
object | Mapping from API ID to API information, used to display API names |
¶ Code Example
Python:
import requests
from collections import defaultdict
url = "https://platform.acedata.cloud/api/v1/usage/apis/aggregate/"
headers = {
"accept": "application/json",
"authorization": "Bearer {token}"
}
params = {
"created_at_from": "2024-08-01T00:00:00Z",
"created_at_to": "2024-08-31T23:59:59Z"
}
response = requests.get(url, headers=headers, params=params)
data = response.json()
# Summarize by API
api_totals = defaultdict(float)
for item in data["results"]:
api_totals[item["api_id"]] += item["amount"]
print(f"Total consumption: {data['total']}")
print("\nGrouped by API:")
for api_id, amount in api_totals.items():
api_name = data["api_map"].get(api_id, {}).get("name", api_id)
print(f" {api_name}: {amount}")
