Usage by API Key
developer/v1/analytics/usage/by-keyReturns usage statistics aggregated by API key — request counts, endpoint distribution, error rates, and last activity timestamps. Essential for multi-application environments where separate API keys track usage per service, team, or deployment environment. Enables internal cost allocation (FinOps chargeback) and per-key anomaly detection.
What It Does
Aggregates usage data grouped by API key ID for the authenticated organization. For each active key, shows: key name, environment (live/test), total request count, endpoint distribution, error count, and last activity timestamp. Keys are sorted by request count descending. Includes all active (non-revoked) keys, even those with zero requests in the period.
Why It's Useful
When multiple applications or teams share an organization account with separate API keys, per-key usage visibility is essential for cost allocation and security monitoring. FinOps principles require cost attribution to specific services or teams for internal chargeback. Security monitoring requires per-key usage baselines to detect anomalous patterns that may indicate key compromise — a key that normally makes 100 requests/day suddenly making 10,000 warrants investigation.
Use Cases
Internal Cost Allocation & Chargeback
Allocate API costs to different teams, projects, or cost centers based on per-key usage. Create monthly chargeback reports showing each team their API consumption. Use key names to identify which application or service drives each cost line.
Accurate internal cost allocation with per-key granularity — teams own their API spending.
Per-Key Security Monitoring
Monitor per-key usage patterns to detect anomalies. Flag keys with sudden usage spikes (possible compromise), keys used from unexpected environments (test key in production), or dormant keys that suddenly become active (possible lateral movement).
Early detection of compromised API keys through behavioral anomaly analysis.
Multi-Application Management
Track which applications consume the most API requests across your microservices architecture. Identify services that could benefit from key-level rate limiting or budget controls. Verify that staging environments use test keys and production uses live keys.
Complete visibility into API consumption across your application portfolio for governance and optimization.
Parameters
| Name | Type | Required | Description |
|---|
Response Fields
| Field | Type | Description |
|---|---|---|
keys | array | Usage stats per API key: key_id, name, environment, request_count, endpoint_distribution, error_count, last_activity |
total_keys | number | Number of active (non-revoked) API keys |
Code Examples
curl "https://api.edgedns.dev/v1/analytics/usage/by-key" \
-H "Authorization: Bearer YOUR_API_KEY"const response = await fetch(
'https://api.edgedns.dev/v1/analytics/usage/by-key',
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
}
);
const data = await response.json();
console.log(data);import requests
response = requests.get(
'https://api.edgedns.dev/v1/analytics/usage/by-key',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={
}
)
data = response.json()
print(data)Read the full Usage by API Key guide
Why it matters, real-world use cases, parameters, response fields, and how to call it from Claude, ChatGPT, or Gemini via MCP.
Read the guide →Related Endpoints
External References
Learn more about the standards and protocols behind this endpoint.
Try This Endpoint
Test the Usage by API Key endpoint live in the playground.