Python SDK

Install and start using the Python SDK.

Intro

The Twilio APIs SDK provides access to the Twilio APIs REST APIs.

This is the public Twilio REST API.

Installation

Add the SDK to your project from its folder, with whichever package manager your project uses. Give each tool a path containing a slash, such as ../twilio-apis — a bare folder name is looked up on PyPI instead, and resolves to whatever project holds that name there:

Terminal
pip install <path-to-sdk>
Terminal
uv add <path-to-sdk>
Terminal
poetry add <path-to-sdk>

Quick Start

Synchronous client

Construct TwilioApisClient with keyword arguments, and call close() when you are done. Every argument is optional.

Python
from twilio_apis import TwilioApisClient
from twilio_apis.core import BasicAuthCredentials

client = TwilioApisClient(
    account_sid_auth_token=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD")
)

client.close()

Alternatively, scope it — with TwilioApisClient(...) as client: closes the pool on exit.

Asynchronous client

AsyncTwilioApisClient mirrors TwilioApisClient with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences — for example, the transport argument is custom_async_http_client.

Python
from asyncio import run

from twilio_apis import AsyncTwilioApisClient
from twilio_apis.core import BasicAuthCredentials


async def main() -> None:
    client = AsyncTwilioApisClient(
        account_sid_auth_token=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD")
    )
    await client.aclose()


run(main())

Alternatively, scope it — async with AsyncTwilioApisClient(...) as client: closes the pool on exit.

On this page