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
fromtb_ce_clientimportThingsboardClientclient=ThingsboardClient(
"http://localhost:9090",
username="tenant@thingsboard.org",
password="tenant",
)devices=client.get_tenant_devices(page_size=10, page=0)
fordeviceindevices.data:
print(device.name, device.id.get_id())fromtb_ce_client.exceptionsimportApiException, NotFoundExceptiontry:
device=client.get_device_by_id(device_id="nonexistent-id")
exceptNotFoundException:
print("Device not found")
exceptApiExceptionase:
print(f"API error {e.status}: {e.body}")Username and password (JWT): Authenticates at construction time via /api/auth/login.
fromtb_ce_clientimportThingsboardClientclient=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:
withThingsboardClient("http://localhost:9090", username="tenant@thingsboard.org", password="tenant") asclient:
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