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
Take the API key in the Teleleo cabinet (Settings → API key) 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
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)
Every method and its arguments are listed in api.md.
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 with exponential backoff: connection errors, 429, and 408/502/503/504 for requests that are safe to repeat. 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.
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.1.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.1.0.tar.gz | 44.5 kB | With provenance | Details for teleleo-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| teleleo-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for teleleo-0.1.0-py3-none-any.whl |
Total release size: 107.6 kB
Release files / teleleo-0.1.0.tar.gz
| Download URL | teleleo-0.1.0.tar.gz |
|---|---|
| Size | 44.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f0e9a77bca51a8e7c0c251ba18e6d21ec007ec34d27355350a380887c325d3f
|
|
BLAKE2b-256 checksum How to use checksums |
1f075dfb6fd73d5308ed99462ba3f9e95a2aa80355c653f16e0bbdaad6776218
|
| 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 10, 2026.
Transparency logRelease files / teleleo-0.1.0-py3-none-any.whl
| Download URL | teleleo-0.1.0-py3-none-any.whl |
|---|---|
| Size | 63.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76c4154c0f52c7455dd67716290db925a3f9c700d8fd7ac08d0b10d80b04a557
|
|
BLAKE2b-256 checksum How to use checksums |
fd2ab9f9e30615b056c2438f90f0405320c83ca8e2b23f9bc8a72f33c50648cc
|
| 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 10, 2026.
Transparency logSecurity for teleleo 0.1.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.1.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 10, 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.