Clips and buffers
Retain an interval, follow rendering and publish a private highlight.
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 recordings:read; clip/buffer controls and operator preview require recordings:create. Publishing also requires streams:publish. CreateClipInput requires recordingId and interval. Choose last, media or wall coordinates, optional cutMode (keyframe or precise), label and retentionSeconds.
Methods
All methods return promises. Their final argument is optional RequestOptions. Input and result names are public imports from @relayrtc/node.
| Method | Signature |
|---|---|
clips.list | (query?: ClipListQuery, options?: RequestOptions): Promise<ClipPage> |
clips.get | (clipId: string, options?: RequestOptions): Promise<ClipResource> |
clips.publish | (clipId: string, options?: RequestOptions): Promise<ClipResource> |
clips.delete | (clipId: string, options?: RequestOptions): Promise<ClipResource> |
streams.clips.create | (streamId: string, input: CreateClipInput, options?: RequestOptions): Promise<ClipResource> |
streams.clips.list | (streamId: string, query?: ClipListQuery, options?: RequestOptions): Promise<ClipPage> |
streams.clips.getWindow | (streamId: string, options?: RequestOptions): Promise<{ data: ClipWindow[]; }> |
streams.clips.getBufferPolicy | (streamId: string, options?: RequestOptions): Promise<{ policy: RollingBufferPolicy | null; version: number; }> |
streams.clips.setBufferPolicy | (streamId: string, input: { policy: RollingBufferPolicy; version: number; }, options?: RequestOptions): Promise<{ policy: RollingBufferPolicy; version: number; }> |
Behavior and results
ClipPage uses data and nextCursor. getWindow identifies available source recordings/buffers and actual retained ranges. setBufferPolicy requires its current version and consent acknowledgment. create returns queued work; wait for ready. publish permits viewer grants but does not replace application entitlement. Completed clips retain their own media independently of source-buffer eviction.
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.