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.
The Compatibility SDK has two primary namespaces:
- REST Client namespace: SignalWire maintains SDKs in popular languages for the Compatibility REST Client. These SDKs streamline the process of requests to the REST API endpoints from within your application.
- cXML namespace: The cXML namespace of the Compatibility SDK does not directly make API calls. Instead, these SDKs or libraries work as simple XML builders that enable you to easily generate cXML within your language of choice. This XML is generated in a single string which SignalWire's servers parse. Learn more by reading our guide to the cXML Specification.
Installing the SDK and Initializing the Client
- Node.js
- Python
- Ruby
- C#
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:
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 Environment Variables
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.
To get started, you will need to replace the Twilio
client with the SignalWire
client and update the from
number
to a valid SignalWire number.
When migrating to SignalWire, make sure to replace the from
numbers with a valid SignalWire number.
// Replace these lines:
const twilio = require('twilio')
const response = new twilio.twiml.VoiceResponse()
// With:
const { RestClient } = require('@signalwire/compatibility-api')
const response = new RestClient.LaML.VoiceResponse()
// Now use response like you did before!
response.say('Hey, welcome to SignalWire!')
The Compatibility API and cXML were previously known as "LāML".
laml
still appears in endpoint URLs, and the cXML namespace of the REST Client is still titled LaML
.
Don't worry, it's all cXML!
Installing the SDK
Install the package using pip:
pip install signalwire
Initializing the Client
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
To get started, you will need to replace the Twilio
client with the SignalWire
client and update the from
number
to a valid SignalWire number.
When migrating to SignalWire, make sure to replace the from
numbers with a valid SignalWire number.
# 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!
Installing the SDK
Install the package via rubygems:
gem install signalwire
Initializing the Client
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:
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
To get started, you will need to replace the Twilio
client with the SignalWire
client and update the from
number
to a valid SignalWire number.
When migrating to SignalWire, make sure to replace the from
numbers with a valid SignalWire number.
# 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!
Installing the SDK
Use nuget to add a reference to the signalwire-dotnet project.
Initializing the Client
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:
TwilioClient.Init("YourProjectID", "YourAuthToken", new Dictionary<string, object> { ["signalwireSpaceUrl"] = "{SPACE}.signalwire.com" });
Migrating from Twilio
To get started, you will need to replace the Twilio
client with the SignalWire
client and update the from
number
to a valid SignalWire number.
When migrating to SignalWire, make sure to replace the from
numbers with a valid SignalWire number.
// Replace these lines:
TwilioClient.Init("accountSid", "authToken");
// With:
TwilioClient.Init("YourProjectID", "YourAuthToken", new Dictionary<string, object> { ["signalwireSpaceUrl"] = "{SPACE}.signalwire.com" });
// Now use client like you did before!