Client Libraries and SDKs

Client Libraries and SDKs

SignalWire has clients in a number of different languages that make using the SignalWire Compatibility API simple and easy. They are also built to make migrating from other service providers to SignalWire a breeze!

📘

Make sure to change the From number!

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

NodeJS

Install the package using NPM:

npm install @signalwire/node

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:

const { RestClient } = require('@signalwire/node')
const client = new RestClient('your-project', 'your-token', { signalwireSpaceUrl: 'example.signalwire.com' })

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

Alternatively, you can use an environment variable to set up the Space URL. Place the Space URL in your .env file:

SIGNALWIRE_SPACE_URL=example.signalwire.com

With this approach, signalwireSpaceUrl will be pulled from the .env for you:

const { RestClient } = require('@signalwire/node')
const client = new RestClient('your-project', 'your-token')

Migrating From Twilio

You can easily migrate from Twilio with minimal changes.

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

// With:
const { RestClient } = require('@signalwire/node')
const client = new RestClient('your-project', 'your-token', { signalwireSpaceUrl: 'example.signalwire.com' })

// Now use client variable like 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/node')
const response = new RestClient.twiml.VoiceResponse()

// Now use response like you did before!
response.say('Hey, welcome to SignalWire!')

PHP

Install the packaging using Composer:

composer require signalwire/signalwire

If your environment does not handle autoloading you must require the autoload file generated by Composer:

<?php
  require 'path-to/vendor/autoload.php';
?>

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

<?php
  use SignalWire\Rest\Client;

  $client = new Client('your-project', 'your-token', array("signalwireSpaceUrl" => "example.signalwire.com"));

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

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

Using $_ENV:

<?php
  $_ENV['SIGNALWIRE_SPACE_URL']="example.signalwire.com";
?>

Using putenv:

<?php
  putenv("SIGNALWIRE_SPACE_URL=example.signalwire.com");
?>

With this approach, signalwireSpaceUrl will be pulled from the .env for you:

<?php
  use SignalWire\Rest\Client;

  $client = new Client('your-project', 'your-token');
?>

Migrating From Twilio

You can easily migrate from Twilio with minimal changes.

<?php
  // Replace this line:
  use Twilio\Rest\Client;

  // With:
  use SignalWire\Rest\Client;

  // Then set up the client with your SignalWire Project ID and API Token:
  $client = new Client('your-project', 'your-token', array("signalwireSpaceUrl" => "example.signalwire.com"));

  // Now use $client variable like you did before!
?>

To generate SignalWire XML:

<?php
  // Replace these lines:
  use Twilio\TwiML;
  $response = new TwiML;

  // With:
  use SignalWire\LaML;
  $response = new LaML;

  // Now use $response like you did before!
  $response->say('Hey, welcome to SignalWire!')
?>

Python

Install the package:

pip install signalwire

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

from signalwire.rest import Client as signalwire_client
client = signalwire_client('your-project', 'your-token', signalwire_space_url = 'example.signalwire.com')

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

Alternatively, you can use an environment variable to set up the Space URL. Place the Space URL in your .env file:

SIGNALWIRE_SPACE_URL=example.signalwire.com

With this approach, signalwire_space_url will be pulled from the .env for you:

from signalwire.rest import Client as signalwire_client
client = signalwire_client('your-project', 'your-token')

Migrating From Twilio

You can easily migrate from Twilio with minimal changes.

# Replace these lines:
from twilio.rest import Client
client = Client('account_sid', 'auth_token')

# With:
from signalwire.rest import Client as signalwire_client
client = signalwire_client('your-project', 'your-token', signalwire_space_url = 'example.signalwire.com')

# Now use client variable like you did before!

To generate SignalWire XML:

# Replace these lines:
from twilio.twiml.voice_response import VoiceResponse
response = VoiceResponse()

# With:
from signalwire.voice_response import VoiceResponse
response = VoiceResponse()

# Now use response like you did before!
response.say('Hey, welcome to SignalWire!')

Ruby

Install the package via rubygems:
gem install signalwire

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

require 'signalwire/sdk'
@client = Signalwire::REST::Client.new 'your-project', 'your-token', signalwire_space_url: "example.signalwire.com"

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

Alternatively, you can use an environment variable to set up the Space URL. Place the Space URL in your .env file:

SIGNALWIRE_SPACE_URL=example.signalwire.com
With this approach, signalwire_space_url will be pulled from the .env for you:

require 'signalwire/sdk'
@client = Signalwire::REST::Client.new 'your-project', 'your-token'

Or, you can configure your SignalWire subdomain with an initializer:

require 'signalwire/sdk'

Signalwire::Sdk.configure do |config|
  config.hostname = "example.signalwire.com"
end

Migrating From Twilio

You can easily migrate from Twilio with minimal changes.

# Replace these lines:
require 'twilio-ruby'
@client = Twilio::REST::Client.new('account_sid', 'auth_token')

# With:
require 'signalwire/sdk'
@client = Signalwire::REST::Client.new 'your-project', 'your-token', signalwire_space_url: "example.signalwire.com"

# Now use @client variable like you did before!

To generate SignalWire XML:

# Replace these lines:
require 'twilio-ruby'
response = Twilio::TwiML::VoiceResponse.new

# With:
require 'signalwire/sdk'
response = Signalwire::Sdk::VoiceResponse.new do |response|

# Now use response like you did before!
response.say(message: 'Hey, welcome to SignalWire!')

C#

Use nuget to add a reference to the signalwire-dotnet project.

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

TwilioClient.Init("YourProjectID", "YourAuthToken", new Dictionary<string, object> { ["signalwireSpaceUrl"] = "<your-domain>.signalwire.com" });

Migrating From Twilio

You can easily migrate from Twilio with minimal changes.

// Replace these lines:
TwilioClient.Init("accountSid", "authToken");

// With:
TwilioClient.Init("YourProjectID", "YourAuthToken", new Dictionary<string, object> { ["signalwireSpaceUrl"] = "<your-domain>.signalwire.com" });

// Now use client like you did before!