Get Recent API Call Status
Through this interface, you can obtain the recent call status of a specific API (last 15 minutes), including success rate and call volume information, for monitoring the health of the API.
This interface does not require authentication.
¶ Interface Description
- Request Method: GET
- Request URL:
https://platform.acedata.cloud/api/v1/apis/{api_id}/usage/ - Request Headers:
- accept:
application/json
- accept:
Where {api_id} is the UUID of the API.
¶ CURL Request Example
curl -X GET \
-H "accept: application/json" \
"https://platform.acedata.cloud/api/v1/apis/{api_id}/usage/"
¶ Sample Return Result
{
"results": [
{
"status_code": 200,
"count": 150
},
{
"status_code": 400,
"count": 5
},
{
"status_code": 500,
"count": 2
}
]
}
¶ Return Field Description
| Field | Type | Description |
|---|---|---|
results |
array | Call statistics grouped by status code |
results[].status_code |
integer | HTTP status code |
results[].count |
integer | Number of calls for that status code |
¶ Applicable Scenarios
This interface is suitable for:
- API Health Monitoring: Monitoring the success rate of the API (proportion of 200), to promptly detect service anomalies.
- Dashboard Display: Displaying the real-time status of the API in the console.
- Alert Triggering: Triggering alerts when the proportion of 5xx errors exceeds a threshold.
¶ Code Example
Python:
import requests
api_id = "api-uuid"
url = f"https://platform.acedata.cloud/api/v1/apis/{api_id}/usage/"
headers = {"accept": "application/json"}
response = requests.get(url, headers=headers)
data = response.json()
total = sum(item["count"] for item in data["results"])
success = sum(item["count"] for item in data["results"] if item["status_code"] == 200)
success_rate = (success / total * 100) if total > 0 else 0
print(f"Total calls: {total}")
print(f"Successful calls: {success}")
print(f"Success rate: {success_rate:.1f}%")
