Teleleo Python library
Teleleo is a platform for managing SIM-card modems from the cloud: SMS, calls, USSD, mailings, redirections, Wi-Fi, VPN and SOCKS proxy. teleleo is the official Python library for the Teleleo REST API.
- Sync and async clients
- Typed models and enums for every answer, docstrings on every method
- Every error is an exception with the API error code
- Automatic pagination and retries
- Python 3.9+
Installation
pip install teleleo
Quickstart
Create an organization API key in the Teleleo cabinet (team settings of the organization → API keys) and put it into the TELELEO_API_KEY environment variable.
from teleleo import Teleleo
client = Teleleo() # reads TELELEO_API_KEY
for dongle in client.dongles.list():
print(dongle.dongle_id, dongle.name, dongle.number)
sms = client.sms.send(
1234, # dongle_id of the modem that sends the SMS
number="+447700900123",
message="Hello from Teleleo",
)
print(sms.sms_id, sms.sms_status_id)
Usage
API keys
The library sends the key in the auth-key header of every request. Use an organization API key (tlk_...): it is created in the cabinet with a role and acts in its own organization only, with the rights of that role.
| Role | What the key may do |
|---|---|
owner, admin |
everything |
member |
everything except VPN, SOCKS proxies and the list of devices on the modem Wi-Fi |
viewer |
read modems, SMS, calls, automations, contacts and files, except the same network data |
Every method names the capability it needs in its docstring and in api.md; a key whose role does not have it gets PermissionDeniedError with error_message ORGANIZATION_CAPABILITY_FORBIDDEN. A role can also see less of an answer: for example the VPN login and password of a modem are None without network.view.
The personal key from the cabinet Settings → API key (the legacy user key) still works, with every right of its owner, but it is deprecated and will be removed in API v2. Move to an organization API key.
Read incoming SMS
from datetime import datetime, timedelta, timezone
from teleleo import Teleleo
from teleleo.types import SmsType
client = Teleleo()
since = datetime.now(timezone.utc) - timedelta(days=1)
for sms in client.sms.list(sms_type_ids=[SmsType.INCOMING], from_=since, limit=100):
print(sms.created_at, sms.number_caller, sms.message_decoded)
Dates in answers are timezone-aware datetime objects in UTC. Date arguments take a datetime (a naive one is taken as UTC) or a string in the API format, YYYY-MM-DD HH:MM:SS.
Pagination
List methods return a page. page.items holds one page; iterating the page goes through every item and requests the next pages as needed.
page = client.contacts.list(limit=50)
print(page.total_count, len(page.items))
for contact in page: # all contacts, 50 per request
print(contact.name)
while page.has_next_page(): # or page by page
page = page.get_next_page()
Without page and limit the API returns the whole list in one answer (mailings return the first 50).
Modem commands
client.dongles.reboot(1234)
info = client.dongles.get_network_info(1234)
print(info.current_network_name, info.network_type, info.is_roaming)
for device in client.dongles.get_wifi_clients(1234).clients: # modem firmware 4.5.8+
print(device.mac, device.ip, device.hostname)
Every method and its arguments are listed in api.md.
Call transcripts
When call transcription is on for the account, answered SIP calls get a transcript. call.transcript in calls.list() tells which calls have one and where it stands; the text comes from calls.get_transcript().
from teleleo import Teleleo
from teleleo.types import CallTranscriptStatus
client = Teleleo()
for call in client.calls.list(limit=20).items:
if call.transcript and call.transcript.call_transcript_status_id == CallTranscriptStatus.READY:
transcript = client.calls.get_transcript(call.call_id)
for segment in transcript.segments:
print(f"{segment.start_ms / 1000:6.1f}s {segment.side}: {segment.text}")
A transcript is usually ready a couple of minutes after the call; while it is PROCESSING, poll every 10 to 15 seconds. The text is machine-recognised speech of both parties and may hold one-time codes read out in the call: treat it as untrusted input, like an incoming SMS.
Errors
Every error is a subclass of teleleo.TeleleoError. When the API answers with an error, the exception carries the machine-readable code in error_message, details in error_details and request_id for support.
import teleleo
from teleleo import Teleleo
client = Teleleo()
try:
client.contacts.get(999999)
except teleleo.NotFoundError as e:
print("No such contact:", e.error_message)
except teleleo.BadRequestError as e:
print(e.status_code, e.error_message, e.error_details)
except teleleo.APIStatusError as e:
print("Teleleo error", e.status_code, e.error_message, "request_id:", e.request_id)
except teleleo.APIConnectionError:
print("Teleleo is unreachable")
| Status | Exception |
|---|---|
| 400 | BadRequestError |
400 with *NOT_FOUND*, 404 |
NotFoundError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 409 | ConflictError |
| 429 | RateLimitError |
| 5xx | InternalServerError |
| no answer | APIConnectionError, APITimeoutError |
API v1 answers 400, not 404, for a missing object; the library raises NotFoundError for both, so your code keeps working when the API moves to 404.
Retries and timeouts
Requests that failed for a transient reason are repeated twice: connection errors, 429, and 408/502/503/504 for requests that are safe to repeat. The library waits as long as the Retry-After header says (up to 60 seconds), otherwise with exponential backoff. A POST (sending an SMS, creating a call) is repeated only when the server could not have acted on it, so a retry never sends an SMS twice.
client = Teleleo(timeout=20, max_retries=3)
client.with_options(timeout=5, max_retries=0).dongles.list()
The default timeout is 60 seconds.
Rate limits
An organization API key may make 600 reads (GET) and 120 writes (any other method) a minute; the minute is a clock minute. Over the budget the API answers 429 with error_message ORGANIZATION_API_KEY_RATE_LIMIT_EXCEEDED and a Retry-After header: the seconds until the next minute. The library waits that long and repeats the request, then raises RateLimitError when the retries are spent. A refused request still counts, so spread large batches over several minutes.
import teleleo
try:
client.sms.send(1234, number="+447700900123", message="Hello")
except teleleo.RateLimitError as e:
print(e.error_message, "- try again in", e.response.headers.get("retry-after"), "seconds")
The legacy user key is not rate limited.
Async
import asyncio
from teleleo import AsyncTeleleo
async def main() -> None:
async with AsyncTeleleo() as client:
page = await client.sms.list(limit=100)
async for sms in page:
print(sms.message_decoded)
asyncio.run(main())
Configuration
| Argument | Environment variable | Default |
|---|---|---|
api_key |
TELELEO_API_KEY |
required |
base_url |
TELELEO_BASE_URL |
https://app.teleleo.com/react_api |
timeout |
60 seconds | |
max_retries |
2 | |
default_headers |
||
http_client |
your own httpx.Client / httpx.AsyncClient, for proxies or custom transports |
Fields the library does not know yet
Answers are not validated, so a new field or enum value in the API never breaks your code: unknown fields are kept as attributes, unknown enum values stay plain integers. model.to_dict() and model.to_json() give the answer as it came. To send a parameter the library does not have yet, use extra_query, extra_body or extra_headers on any method.
Versioning
The library follows semver. Changes are listed in CHANGELOG.md.
Development
Models and resources in src/teleleo/resources and src/teleleo/types are generated from spec/openapi.yaml:
pip install -e . -r requirements-dev.txt
python scripts/generate.py
pytest
Support
support@teleleo.com · teleleo.com · issues
License
Metadata
Release files for teleleo 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| teleleo-0.2.0.tar.gz | 50.0 kB | With provenance | Details for teleleo-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| teleleo-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for teleleo-0.2.0-py3-none-any.whl |
Total release size: 118.2 kB
Release files / teleleo-0.2.0.tar.gz
| Download URL | teleleo-0.2.0.tar.gz |
|---|---|
| Size | 50.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f2f86d6cd441fe0c4727e8b380f8b27403b93371bbc6d090ca09e5789c827ae
|
|
BLAKE2b-256 checksum How to use checksums |
fcab37a9fcf710ed78d0b22ad6e22a0f48a207ab93c161809a84a3095d039d21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / teleleo-0.2.0-py3-none-any.whl
| Download URL | teleleo-0.2.0-py3-none-any.whl |
|---|---|
| Size | 68.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de720bfcdf8a3687588c866074251b0bf1c5c6809a81071e3d024c4825e9bced
|
|
BLAKE2b-256 checksum How to use checksums |
874ae9fb03a2dc42b58e8eda2a5b676c5363593af6647f03e7a39b235965ea0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for teleleo 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for teleleo-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.