Skip to main content

Telnyx Twexit API client

Project description

Telnyx "Twexit" Python Library

The Telnyx "Twexit" Python library allows users to send messages and validate webhooks with minimal changes to their existing Twilio messaging code.

Installation

This SDK can be installed either via pip:

pip install twexit

or direct from source by downloading and unzipping the repository from here, then from within the twexit-python folder, run

python setup.py install

Account Setup

  1. Complete the Portal Setup to set up a messaging-enabled number.

  2. Follow the additional Twexit setup steps to configure webhooks

Usage

Send a message

from twilio.rest import Client

# Your organization ID from
account_sid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# An API key from https://portal.telnyx.com/#/app/api-keys
auth_token = "KEY0123456789xxxxx"

message = client.messages.create(
    to="+13125550123",
    from_="+16165550123",
    body="Free yourself with Twexit!"
)

print(message.sid)

Webhook Validation

Twexit uses a fast asymmetric signing algorithm, Ed25519, to avoid issues discovered with SHA-1. To switch from the HMAC-SHA1 signing method, follow these steps:

  1. Obtain your account's public key at https://portal.telnyx.com/#/app/account/public-key

  2. Update your application to use the TwexitRequestValidator instead of RequestValidator

  3. Extract the X-Twexit-Signature from the request and provide that when calling the validator.

from twilio.request_validator import TwexitRequestValidator

public_key = "abcdef123456xxxxx"

validator = TwexitRequestValidator(public_key)

url = 'https://mycompany.com/myapp.php?foo=1&bar=2'
params = {
    "MessageSid": "CA1234567890ABCDE",
    "ApiVersion": "2010-04-01",
    "Body": "Aloha!",
    "From": "+13125550123",
    "To": "+16165550123",
}

# The X-Twexit-Signature header attached to the request
twexit_signature = '0/KCTR6DLpKmkAf8muzZqo1nDgQ='

print(validator.validate(url, params, twexit_signature))

Caveats

This SDK currently only provides the capability to send messages via REST and validate webhooks when receiving messages. Configuration of the messaging product and other products (voice, fax) are not yet supported.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twexit-6.43.0b1.tar.gz (447.0 kB view details)

Uploaded Source

Built Distribution

twexit-6.43.0b1-py2.py3-none-any.whl (1.1 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file twexit-6.43.0b1.tar.gz.

File metadata

  • Download URL: twexit-6.43.0b1.tar.gz
  • Upload date:
  • Size: 447.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

File hashes

Hashes for twexit-6.43.0b1.tar.gz
Algorithm Hash digest
SHA256 24efea4267bceb59db382b2fd9e85bb625c7fc5360800f010a4fce59e4c9dceb
MD5 3923d54f74e4da3011e7f85881956dbf
BLAKE2b-256 51f022082da0be219ff0aadfa4037d4af657aedae01cdf685924c9e9f6d15275

See more details on using hashes here.

File details

Details for the file twexit-6.43.0b1-py2.py3-none-any.whl.

File metadata

  • Download URL: twexit-6.43.0b1-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

File hashes

Hashes for twexit-6.43.0b1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c12821ee5b6dfc997f96a9a6b464066c5da9b7b20e930da9b7e35d274e688ae1
MD5 7e9554013fccf7afd879dd0820b33970
BLAKE2b-256 b95d677acdbe1f09e581567c5f7abda5d2d3f99d3e528444bcb52fc45d81dedc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page