Skip to main content

Client Libraries and SDKs

SignalWire has clients in a number of different languages that make using the SignalWire Compatibility API possible with your existing application. They are also built to make migrating from other service providers to SignalWire quick and easy.

Make sure to change the "From" number!

When migrating to SignalWire, make sure to replace the from numbers with a valid SignalWire number.

Installing the SDK

Install the package using NPM:

npm install @signalwire/compatibility-api

Initializing the Client

In order to use the NodeJS client, you must get your Space URL, Project ID, and API Token from your SignalWire Dashboard and initialize the client:

Explicitly:

const { RestClient } = require("@signalwire/compatibility-api");

const client = RestClient(
"your-project",
"your-token",
{ signalwireSpaceUrl: "example.signalwire.com" }
);

// You can then use client to make calls, send messages, and more.

Using .env:

Alternatively, you can use an environment variable to pass the Space URL:

SIGNALWIRE_SPACE_URL=example.signalwire.com

With this approach, signalwireSpaceUrl will be pulled from the .env file instead of having to be passed as an argument:

const { RestClient } = require("@signalwire/compatibility-api");

const client = RestClient(
"your-project",
"your-token"
);

Migrating from Twilio

You can easily migrate from Twilio with minimal changes. Simply install the package as discussed above, then initialize the client:

// Replace these lines:
const twilio = require("twilio");
const client = new twilio(sid, token);

// With:
const { RestClient } = require("@signalwire/compatibility-api");
const client = RestClient("your-project", "your-token", {
signalwireSpaceUrl: "example.signalwire.com",
});

// Now use the client variable as you did before!

To generate SignalWire XML:

// Replace these lines:
const twilio = require("twilio");
const response = new twilio.twiml.VoiceResponse();

// With:
const { RestClient } = require("@signalwire/compatibility-api");
const response = RestClient.laml.VoiceResponse();

// Now use response as you did before!
response.say("Hey, welcome to SignalWire!");