> This page is for Compatibility API.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# REST client 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 components:

* **REST Client:** The REST client is used to make API calls for initiating outbound calls and messages, managing phone numbers, retrieving call logs, and other operations. See the [REST API documentation](/docs/compatibility-api/rest) for the complete API reference.
* **cXML Builders:** The cXML builders do not make API calls directly. Instead, they are helper libraries that enable you to easily generate cXML responses within your language of choice. The SDK provides three response builders for the different channel types:

  * `VoiceResponse` — Build XML for handling voice calls
  * `MessagingResponse` — Build XML for handling SMS/MMS messages
  * `FaxResponse` — Build XML for handling faxes

  See the [cXML Specification](/docs/compatibility-api/cxml) for technical reference on the XML format and available verbs.

#### [Node.js](https://github.com/signalwire/compatibility-api-js)

#### [Python](https://github.com/signalwire/signalwire-python)

#### [Ruby](https://github.com/signalwire/signalwire-ruby)

#### [C# / .NET](https://github.com/signalwire/signalwire-dotnet-lite)

---

## Getting started with the SDKs

#### Node.js

### 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.

> **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!')
```

#### Python

### 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.

> **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!
```

#### Ruby

### Installing the SDK

Install the package via rubygems:

```bash
gem install signalwire
```

---

### Initializing the Client

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:

```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.

> **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!
```

#### C\#

### 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 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<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.

> **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<string, object> { ["signalwireSpaceUrl"] = "{SPACE}.signalwire.com" });

// Now use client like you did before!
```

---

\*Twilio and TwiML are trademarks of Twilio, Inc. SignalWire, Inc. and its products are not affiliated with or endorsed by Twilio, Inc.