Auto-generated Python REST clients for ThingsBoard IoT platform. Available for Community Edition (CE), Professional Edition (PE), and PaaS.
pip install tb-ce-client # Community Edition
# pip install tb-pe-client # Professional Edition
# pip install tb-paas-client # PaaS
from tb_ce_client import ThingsboardClient
client = ThingsboardClient(
"http://localhost:9090",
username="tenant@thingsboard.org",
password="tenant",
)devices = client.get_tenant_devices(page_size=10, page=0)
for device in devices.data:
print(device.name, device.id.get_id())from tb_ce_client.exceptions import ApiException, NotFoundException
try:
device = client.get_device_by_id(device_id="nonexistent-id")
except NotFoundException:
print("Device not found")
except ApiException as e:
print(f"API error {e.status}: {e.body}")Username and password (JWT): Authenticates at construction time via /api/auth/login.
from tb_ce_client import ThingsboardClient
client = ThingsboardClient(
"http://localhost:9090",
username="tenant@thingsboard.org",
password="tenant",
)API key: Sets X-Authorization: ApiKey <key> header on every request; no login call is made.
client = ThingsboardClient("http://localhost:9090", api_key="your-api-key")Pre-existing token: Injects an externally obtained JWT; no login call is made.
client = ThingsboardClient(
"http://localhost:9090",
token="eyJhbGciOi...",
refresh_token="eyJhbGciOi...",
)Use the client as a context manager so close() is called automatically on exit:
with ThingsboardClient("http://localhost:9090", username="tenant@thingsboard.org", password="tenant") as client:
devices = client.get_tenant_devices(page_size=10, page=0)| Edition | Package | Install |
|---|---|---|
| Community Edition | tb-ce-client |
pip install tb-ce-client |
| Professional Edition | tb-pe-client |
pip install tb-pe-client |
| PaaS | tb-paas-client |
pip install tb-paas-client |
- API documentation — per-controller and model reference for CE
- Usage examples — copy-paste examples for common operations
- ThingsBoard — official platform site