External sources
Register, probe and operate approved HLS pulls or monitored push encoders.
On this page
These methods run on your backend and require a compatible API/SDK build; see installation.
Import and client
Set RELAYRTC_API_URL and RELAYRTC_SECRET_KEY in your backend environment. Keep the secret key on the server.
import { RelayServer } from '@relayrtc/node'
const relay = new RelayServer({
apiUrl: process.env.RELAYRTC_API_URL!,
apiKey: process.env.RELAYRTC_SECRET_KEY!,
})Authorization and inputs
Reads require streams:read; source mutations require streams:write; start also requires streams:publish. CreateRestreamSourceInput requires streamId, name, protocol and redistributionAuthorized: true. Only hls_pull accepts endpoint/authorization; it attaches to an RTMP stream. rtmp_push and whip_push attach to matching stream kinds.
Methods
All methods return promises. Their final argument is optional RequestOptions. Input and result names are public imports from @relayrtc/node.
| Method | Signature |
|---|---|
restreamSources.create | (input: CreateRestreamSourceInput, options?: RequestOptions): Promise<RestreamSource> |
restreamSources.list | (query?: { cursor?: string; limit?: number; }, options?: RequestOptions): Promise<{ data: RestreamSource[]; nextCursor: string | null; }> |
restreamSources.get | (sourceId: string, options?: RequestOptions): Promise<RestreamDetail> |
restreamSources.update | (sourceId: string, input: UpdateRestreamSourceInput, options?: RequestOptions): Promise<RestreamSource> |
restreamSources.delete | (sourceId: string, options?: RequestOptions): Promise<{ id: string; deleted: true; }> |
restreamSources.probe | (sourceId: string, options?: RequestOptions): Promise<RestreamDetail> |
restreamSources.start | (sourceId: string, options?: RequestOptions): Promise<RestreamDetail> |
restreamSources.stop | (sourceId: string, options?: RequestOptions): Promise<RestreamDetail> |
Behavior and results
Update requires the current version. Stream/protocol bindings are immutable. Stop the active session before editing. Probe is asynchronous: read state until ready or failed before starting a pull. RestreamDetail includes the current session, safe recent health transitions and observed fetch/processing usage. Pull hosts must be explicitly allowed by the deployment.
Requests and errors
Streaming commands generate an idempotency key when omitted. Use an explicit stable key when retrying an uncertain application command; reuse its payload and target. Mutations do not retry automatically. Read retries and cancellation follow RequestOptions. A canceled HTTP request does not undo committed server work.
Failures throw RelayApiError. Reload resources after version conflicts; inspect asynchronous operation/processing states before reporting completion.
See REST parameters, defaults and errors and the public type index.