import Tabs from @theme/Tabs; import TabItem from @theme/TabItem; import LamlAdmonition from ../laml-admonition.md; # 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 SignalWires servers parse. Learn more by reading our guide to the [CXML Specification](../cxml/index.mdx). ## Installing the SDK and Initializing the Client Installing the SDK
Install the package using NPM: js 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: js 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: makefile 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: js 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. :::info Make sure to change the From number! When migrating to SignalWire, make sure to replace the from numbers with a valid SignalWire number. ::: js // 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!) Installing the SDK
Install the package using pip: bash 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: python 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: makefile SIGNALWIRE_SPACE_URL=example.signalwire.com With this approach, signalwire_space_url will be pulled from the .env for you: python 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. :::info Make sure to change the From number! When migrating to SignalWire, make sure to replace the from numbers with a valid SignalWire number. ::: python # 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: bash 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: ruby 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: makefile SIGNALWIRE_SPACE_URL=example.signalwire.com With this approach, signalwire_space_url will be pulled from the .env for you: ruby require signalwire/sdk @client = Signalwire::REST::Client.new your-project, your-token Or, you can configure your SignalWire subdomain with an initializer: ruby 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. :::info Make sure to change the From number! When migrating to SignalWire, make sure to replace the from numbers with a valid SignalWire number. ::: ruby # 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](https://www.nuget.org/packages/SignalWire-DotNet/) 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: csharp TwilioClient.Init(YourProjectID, YourAuthToken, new DictionaryMigrating 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. :::info Make sure to change the From number! When migrating to SignalWire, make sure to replace the from numbers with a valid SignalWire number. ::: csharp // Replace these lines: TwilioClient.Init(accountSid, authToken); // With: TwilioClient.Init(YourProjectID, YourAuthToken, new Dictionary