Twilio

Tools & Infrastructure 💻 Python ⚖️ MIT 🟢 Actively maintained
2.1k stars

twilio-python is the official Python helper library for the Twilio API. It simplifies sending SMS, making calls, and managing Twilio resources from Python applications. It is intended for developers building communications features into their Python projects.

✨ Key features

  • Send and receive SMS messages
  • Make and manage phone calls
  • Generate TwiML for call control
  • Support for synchronous and asynchronous requests
  • Automatic pagination for listing resources
  • Environment variable and API key authentication

🎯 Use cases

  • Send SMS notifications from a Python app
  • Build a voice call system with TwiML responses
  • Retrieve call logs and message history
  • Integrate Twilio into web apps for two-factor authentication

📦 Installation

🧰 Requirements: Python 3.10 or later; Twilio account SID and auth token (or API key/secret) for authentication.

pip3 install twilio

If pip fails on Windows due to path length, enable Long Paths or use a shorter directory. Alternatively, download the source and run:

python3 setup.py install

🚀 Usage

from twilio.rest import Client

# Your Account SID and Auth Token from console.twilio.com
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"

client = Client(account_sid, auth_token)

message = client.messages.create(
    to="+15558675309",
    from_="+15017250604",
    body="Hello from Python!")

print(message.sid)

Save as send_sms.py and run with python3 send_sms.py.

⚠️ Good to know

The library uses a modified semantic versioning; supports Python 3.10-3.13; Docker image is for testing only.

❓ FAQ

How do I authenticate without hardcoding credentials?

You can use environment variables TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN, or pass API key and secret to the Client constructor.

Can I make asynchronous API calls?

Yes, use AsyncTwilioHttpClient and the *_async methods, e.g., client.messages.create_async().

How do I handle errors from Twilio?

Catch TwilioRestException from twilio.base.exceptions around your API calls.

How do I generate TwiML?

Use twilio.twiml.voice_response.VoiceResponse to build responses and convert to string with str(r).

📊 Repository

Stars★ 2,079
Forks🍴 812
Open issues🐛 70
Last commit🕒 Sep 4, 2026
Created📅 Sep 2009
Language💻 Python
License⚖️ MIT

🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.