RelayrtcDocs
Get started
Documentation
Node SDK

usage.get

Read scoped usage across one category or all public categories.

On this page

Import and client

TypeScript
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

OptionTypeDefault / requirementPurpose
categoryUsageCategoryallall, rooms, participants, sfu, turn, signaling, screen-share or streaming.
rangeUsageRange7d24h, 7d, 14d or 30d.
startedAtISO datetimeWith endedAtCustom window start. Cannot combine with range.
endedAtISO datetimeWith startedAtCustom exclusive end, no later than now.
granularityhour or dayAutomatichour for ≤24h windows, otherwise day.
projectIdstringKey projectMust match the key.
environmentIdstringKey environmentMust match the key.

A custom window must be positive, no longer than 30 days and within retained history. Pass RequestOptions after the query.

Example

TypeScript
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.

TypeScript
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.