import Tabs from @theme/Tabs; import TabItem from @theme/TabItem; # 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. :::info 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: js npm install @signalwire/compatibility-api Install the packaging using Composer: php composer require signalwire-community/signalwire If your environment does not handle autoloading you must require the autoload file generated by Composer: php Install the package: python pip install signalwire Install the package via rubygems: ruby gem install signalwire 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 NodeJS client, you must get your **Space URL**, **Project ID**, and **API Token** from your SignalWire Dashboard and initialize the client: **Explicitly:** javascript 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: javascript const { RestClient } = require(@signalwire/compatibility-api); const client = RestClient( your-project, your-token ); 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 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 **Using putenv:** php With this approach, signalwireSpaceUrl will be pulled from the .env for you: php 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: 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) 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: 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: 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 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: csharp TwilioClient.Init(YourProjectID, YourAuthToken, new Dictionary { [signalwireSpaceUrl] = .signalwire.com }); ## Migrating from Twilio You can easily migrate from Twilio with minimal changes. Simply install the package as discussed above, then initialize the client: javascript // 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! php example.signalwire.com)); // Now use $client variable like you did before! ?> 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! 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! c# // Replace these lines: TwilioClient.Init(accountSid, authToken); // With: TwilioClient.Init(YourProjectID, YourAuthToken, new Dictionary { [signalwireSpaceUrl] = .signalwire.com }); // Now use client like you did before! To generate SignalWire XML: javascript // 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!); php say(Hey, welcome to SignalWire!) ?> python # 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 # 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!)