Server SDK

@radist-tech/server

Server SDK for trusted runtimes. Create P2P calls or SFU rooms from your backend and receive participant tokens to hand to your users.

Install

Shell
npm install @radist-tech/server

API reference

Constructor options

Environment variable fallback

When projectId and secretToken are omitted, the SDK reads RADIST_PROJECT_ID and RADIST_KEY from the runtime environment.

OptionTypeDescription
projectIdstringProject id. Required unless RADIST_PROJECT_ID is available in the runtime.
secretTokenstringSecret project key from the project Keys section. Required unless RADIST_KEY is available.
fetchFetchLikeOptional custom fetch implementation for Node, Bun, Deno, tests, or proxies.

Methods

SymbolReturnsDescription
new RadistServerClient(secretToken?)RadistServerClientPass the secret token string; request methods still need a project id option or RADIST_PROJECT_ID.
new RadistServerClient(options?)RadistServerClientReads configuration from the options object and resolves env vars when needed.
createP2PConnection(options?)Promise<CreateP2PConnectionResponse>Creates a two-peer call and returns two server-minted participant tokens. Pass { accessControl: "public" } to allow anyone with your public key to join; defaults to "private".
createRoom()Promise<CreateRoomResponse>Creates an SFU room and returns two server-minted room tokens.
mintConnectionToken({ callId } | { roomId })Promise<MintConnectionTokenResponse>Mints an additional participant token for an existing P2P connection or SFU room.
RadistServeralias of RadistServerClientConvenience export with the same constructor and methods.
RadistApiErrorError with statusThrown when the API responds with a non-2xx status or invalid JSON payload.

Access control

Calls are private by default: only tokens minted server-side with your secret key are accepted. The public-key endpoint (used by the easy interface and client SDK) returns 403 for private calls, so you control who joins by distributing tokens yourself. Set accessControl: "public" to allow anyone with your public key to join — useful for demos.

TypeScript
// Private (default) — only your server can mint tokens for this call:
const { callId, callTokens } = await radist.createP2PConnection();
// or equivalently:
const { callId, callTokens } = await radist.createP2PConnection({ accessControl: "private" });

// Public — anyone with your public key can join via the easy interface:
const { callId, callTokens } = await radist.createP2PConnection({ accessControl: "public" });

// For private calls, mint additional tokens server-side as needed:
const { connectionToken } = await radist.mintConnectionToken({ callId });

P2P example

Create a call on your backend and send one token to each approved participant.

TypeScript
import { RadistServerClient } from '@radist-tech/server';

const radist = new RadistServerClient({
  projectId: process.env.RADIST_PROJECT_ID,
  secretToken: process.env.RADIST_KEY
});

export async function createRadistSession() {
  const { callId, callTokens } = await radist.createP2PConnection();
  const [hostCallToken, guestCallToken] = callTokens;

  return { callId, hostCallToken, guestCallToken };
}

SFU room example

For multi-party calls, create one SFU room and mint extra participant tokens as needed.

TypeScript
export async function createRoomSession(participantCount: number) {
  const { roomId, roomTokens } = await radist.createRoom();

  // createRoom returns two tokens; mint one per extra participant
  while (roomTokens.length < participantCount) {
    const { connectionToken } = await radist.mintConnectionToken({ roomId });
    roomTokens.push(connectionToken);
  }

  return { roomId, roomTokens };
}