Skip to main content

Overview

The RELAY v4 SDK significantly improves the RELAY v3 SDK by introducing a unified client architecture that consolidates multiple communication functionalities into a single client. This enhancement simplifies the development process, reducing code complexity and making applications easier to maintain. Relay V4 also improves event handling and promise resolution, offering more precise control over application flows and asynchronous operations. These improvements make RELAY v4 more intuitive and efficient for developers, enabling the creation of sophisticated real-time communication applications with greater ease and flexibility.

Installation

npm install @signalwire/realtime-api

Getting started

To get started, create a Realtime-Client

Once you have a client, you can then choose a namespace to work with. Each namespace provides a set of methods to interact with the SignalWire RealTime APIs.

Here is an example of how to use the Voice namespace to make an outbound phone call:

import { SignalWire, Voice } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

const voiceClient = client.voice

try {
const call = await voiceClient.dialPhone({
from: "+YYYYYYYYYY",
to: "+XXXXXXXXXX",
timeout: 30
});
console.log("Call answered.", call);
} catch (e) {
console.log("Call not answered.", e);
}

Namespaces