---
title: "Get API key analytics"
method: GET
path: "/analytics/api_keys"
tags: ["API Keys", "dev-api"]
---

# Get API key analytics

`GET /analytics/api_keys`

## Request

- Base URL: `https://gateway.prem.io`
- URL: `https://gateway.prem.io/analytics/api_keys`
- Auth: HTTP bearer and API key in header `Authorization`

Get analytics data for API key usage

## Query parameters

- `api_key_id` union
  - string
  - string[]
- `timezone` string
- `period` 'last_hour' | 'last_2_hours' | 'last_6_hours' | 'last_12_hours' | 'last_day' | 'last_week' | 'last_30_days'

## Response `200`

Successful API key analytics response

- object
  - `status` 200 | 201 | 202, required: Status code of the response
  - `data` object, nullable, required
    - `period` 'last_hour' | 'last_2_hours' | 'last_6_hours' | 'last_12_hours' | 'last_day' | 'last_week' | 'last_30_days', required: The window these metrics cover
    - `timezone` string, required: Zone the day-grain buckets were grouped in. UTC unless a valid zone was requested.
    - `bucket_seconds` integer, required: Width of each hourly_metrics bucket in seconds
    - `core_metrics` object, required
      - `total_requests` integer, nullable: Total number of API requests
      - `requests_per_second` number, nullable: Average requests per second
      - `total_success` integer, nullable: Requests that answered 2xx
      - `total_errors` integer, nullable: Requests that answered 5xx. A 4xx is a rejected request rather than a failure to serve, so it counts toward neither this nor total_success
      - `success_rate_pct` number, nullable: 2xx share of requests; 3xx and 4xx count toward neither success nor error
      - `avg_latency_ms` number, nullable: Mean gateway time in milliseconds
      - `under_10ms` integer: Requests whose gateway time was under 10ms
      - `from_10_to_50ms` integer: Requests whose gateway time was 10ms up to 50ms
      - `from_50_to_200ms` integer: Requests whose gateway time was 50ms up to 200ms
      - `over_200ms` integer: Requests whose gateway time was 200ms or more
      - `pct_under_10ms` number, nullable: Share of requests whose gateway time was under 10ms
      - `pct_under_50ms` number, nullable: Share of requests whose gateway time was under 50ms
      - `pct_under_200ms` number, nullable: Share of requests whose gateway time was under 200ms
      - `unique_endpoints` integer, nullable: Number of unique endpoints called
      - `distinct_api_keys` integer, nullable: Number of distinct API keys used
    - `prev_core_metrics` object, required
      - `total_requests` integer, nullable: Total number of API requests
      - `requests_per_second` number, nullable: Average requests per second
      - `total_success` integer, nullable: Requests that answered 2xx
      - `total_errors` integer, nullable: Requests that answered 5xx. A 4xx is a rejected request rather than a failure to serve, so it counts toward neither this nor total_success
      - `success_rate_pct` number, nullable: 2xx share of requests; 3xx and 4xx count toward neither success nor error
      - `avg_latency_ms` number, nullable: Mean gateway time in milliseconds
      - `under_10ms` integer: Requests whose gateway time was under 10ms
      - `from_10_to_50ms` integer: Requests whose gateway time was 10ms up to 50ms
      - `from_50_to_200ms` integer: Requests whose gateway time was 50ms up to 200ms
      - `over_200ms` integer: Requests whose gateway time was 200ms or more
      - `pct_under_10ms` number, nullable: Share of requests whose gateway time was under 10ms
      - `pct_under_50ms` number, nullable: Share of requests whose gateway time was under 50ms
      - `pct_under_200ms` number, nullable: Share of requests whose gateway time was under 200ms
      - `unique_endpoints` integer, nullable: Number of unique endpoints called
      - `distinct_api_keys` integer, nullable: Number of distinct API keys used
    - `most_used_api_keys` object[], required
      - `api_key_id` string, required: API key id
      - `api_key_label` string, nullable, required: API key label, null when the key no longer exists
      - `usage_count` integer, required: Number of requests made with this API key
      - `total_success` integer, required: Number of 2xx responses served to this API key
      - `success_rate` number, required: 2xx share of requests made with this API key; 3xx and 4xx count toward neither success nor error
    - `ip_metrics` object[], required: Metrics by IP address
      - `ip` string, nullable: IP address
      - `total_requests` integer: Total number of requests from this IP
      - `total_success` integer: Number of 2xx responses served to this IP
      - `success_rate` number: 2xx share of requests from this IP; 3xx and 4xx count toward neither success nor error, so this and error_rate do not sum to 100
      - `total_errors` integer: Number of 5xx responses served to this IP
      - `error_rate` number: 5xx share of requests from this IP
      - `country_code` string, nullable: ISO country code from the latest IP lookup, null when the address has never been looked up
      - `city` string, nullable: City from the latest IP lookup
      - `isp` string, nullable: ISP from the latest IP lookup
    - `hourly_metrics` object[], required: Metrics per time bucket across the period; each bucket is bucket_seconds wide
      - `hour` string: Bucket start. An hour boundary at hour grain, the exact bucket start at finer grains.
      - `total_requests` integer: Total number of requests in this hour
      - `success_count` integer: 2xx responses in this bucket
      - `error_count` integer: Number of 5xx responses in this bucket
      - `error_rate_pct` number: 5xx share of requests in this bucket
      - `avg_latency_ms` number: Average latency in milliseconds for this hour
      - `success_rate_pct` number: 2xx share of requests in this bucket; 3xx and 4xx count toward neither success nor error, so this and error_rate_pct do not sum to 100
      - `unique_endpoints` integer: Distinct paths seen in this bucket
      - `distinct_api_keys` integer: Distinct API keys seen in this bucket
    - `latency_breakdown` object, nullable, required: Disjoint histogram of gateway time. For inference that is routing only; other routes measure the whole request.
      - `total_requests` integer: Total number of requests
      - `under_10ms` integer: Requests whose gateway time was under 10ms
      - `from_10_to_50ms` integer: Requests whose gateway time was 10ms up to 50ms
      - `from_50_to_200ms` integer: Requests whose gateway time was 50ms up to 200ms
      - `over_200ms` integer: Requests whose gateway time was 200ms or more
    - `latency` object, nullable, required: API Keys latency metrics
      - `min` number, float: Minimum latency in milliseconds for API Request deliveries
      - `max` number, float: Maximum latency in milliseconds for API Request deliveries
      - `avg` number, float: Average latency in milliseconds for API Request deliveries
      - `p50` number, float: 50th percentile latency in milliseconds for API Request deliveries
      - `p90` number, float: 90th percentile latency in milliseconds for API Request deliveries
      - `p95` number, float: 95th percentile latency in milliseconds for API Request deliveries
      - `p99` number, float: 99th percentile latency in milliseconds for API Request deliveries
  - `error` string, nullable: Error message of the response, human readable
  - `message` string, nullable, required: Message of the response, human readable
  - `env` 'development' | 'production', required: API environment
  - `log` union: Useful informaiton, not always present, to debug the response
    - string
    - object
  - `validator` union: Validator response object, each key is the field name and value is the error message
    - object
    - unknown[]
      - unknown
  - `support_id` string, uuid, nullable: Support ID linked to the response, used to identify it when talking with our team.

## Other responses

- `400`: Bad request
- `401`: Access token is missing or invalid
- `403`: You do not have the required permissions to access this resource
- `429`: Too many requests

## Changes

- **2026-11-13** `d46bc3931b34`: 3 breaking, 17 warning, 40 info
  - the `allOf[#/components/schemas/apiKeyAnalyticsResponse]/data/hourly_metrics` response's property type changed from `array, object` to `array` for status `200`
  - the `allOf[#/components/schemas/apiKeyAnalyticsResponse]/data/ip_metrics` response's property type changed from `array, object` to `array` for status `200`
  - removed the required property `allOf[#/components/schemas/apiKeyAnalyticsResponse]/data/api_key_metrics_30d` from the response with the `200` status
  - removed the optional property `allOf[#/components/schemas/apiKeyAnalyticsResponse]/data/core_metrics/pct_under_100ms` from the response with the `200` status
  - …56 more
- **2026-10-16** `d5b1beb33be5`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/premai-io/apis/prem-studio-api/changes/analytics/api_keys/get.md)

---

[API](https://skmtc.dev/premai-io/apis/prem-studio-api.md) - [All operations](https://skmtc.dev/premai-io/apis/prem-studio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/premai-io/apis/prem-studio-api/revisions/d46bc3931b34?raw)
