usage.get
Read scoped usage across one category or all public categories.
On this page
Import and client
import { RelayServer } from '@relayrtc/node'
const relay = new RelayServer({
apiUrl: process.env.RELAYRTC_API_URL!,
apiKey: process.env.RELAYRTC_SECRET_KEY!,
})Requirements
A secret key with usage:read. The result is restricted to its project and environment.
Query
| Option | Type | Default / requirement | Purpose |
|---|---|---|---|
| category | UsageCategory | all | all, rooms, participants, sfu, turn, signaling, screen-share or streaming. |
| range | UsageRange | 7d | 24h, 7d, 14d or 30d. |
| startedAt | ISO datetime | With endedAt | Custom window start. Cannot combine with range. |
| endedAt | ISO datetime | With startedAt | Custom exclusive end, no later than now. |
| granularity | hour or day | Automatic | hour for ≤24h windows, otherwise day. |
| projectId | string | Key project | Must match the key. |
| environmentId | string | Key environment | Must match the key. |
A custom window must be positive, no longer than 30 days and within retained history. Pass RequestOptions after the query.
Example
const usage = await relay.usage.get({
category: 'participants',
range: '7d',
granularity: 'day',
})
console.log(usage.summary.participantMinutesDerived)Returns
Promise<UsageResponse>: scope, category, window, bucketDefinition, metricDefinitions, summary, buckets and dataQuality.
Matching SDK/API releases also support category: 'streaming' and the optional serviceUsage report. It is returned for all and streaming; other categories omit it. A streaming-only response has an empty RTC summary and RTC bucket metrics. Read service measurements from usage.serviceUsage.summary, with their own metricDefinitions and coverage, rather than from the RTC summary. Published SDK versions can lag these additions.
const streamingUsage = await relay.usage.get({ category: 'streaming', range: '24h' })
if (streamingUsage.serviceUsage) {
console.log(streamingUsage.serviceUsage.summary.liveDeliveryBytes)
console.log(streamingUsage.serviceUsage.coverage.liveDeliveryBytes)
}Service measurements are unpriced quantities, not enforced quotas or calculated charges. The public usage.get method accepts the preset ranges listed above; the rolling live window belongs to resource usage reports, which remain REST-only. See response fields.
Metrics use the units defined by the response. 5.538 participant minutes means about 5.5 minutes, not thousands. See usage interpretation.
REST equivalent
Calls GET /v1/usage for all categories or GET /v1/usage/{category} for one category. The category belongs in the path, not the REST query string.