Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
180 Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

Python REST Client (Legacy)

The ThingsBoard Python REST Client wraps the Edge REST API and lets Python scripts manage devices, assets, dashboards, customers, and other entities on your Edge node. It supports context managers for automatic token refresh and connects directly to the Edge node’s local REST endpoint.

Terminal window
pip3 install tb-rest-client==4.3.1.6

Point the client at your Edge node’s local address — default http://localhost:8080.

import logging
from tb_rest_client.rest_client_ce import *
from tb_rest_client.rest import ApiException
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(module)s - %(lineno)d - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
url = "http://localhost:8080"
api_key = "YOUR_API_KEY_HERE"
def main():
with RestClientCE(base_url=url) as rest_client:
try:
rest_client.api_key_login(api_key)
device_profile = DeviceProfile(name="Thermometer",
type="DEFAULT",
transport_type="DEFAULT",
profile_data=DeviceProfileData(
configuration={"type": "DEFAULT"},
import logging
from tb_rest_client.rest_client_ce import *
from tb_rest_client.rest import ApiException
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(module)s - %(lineno)d - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
url = "http://localhost:8080"
username = "[email protected]"
password = "tenant"
def main():
with RestClientCE(base_url=url) as rest_client:
try:
rest_client.login(username=username, password=password)
default_asset_profile_id = rest_client.get_default_asset_profile_info().id
asset = Asset(name="Building 12", asset_profile_id=default_asset_profile_id)
asset = rest_client.save_asset(asset)
logging.info("Asset was created:\n%r\n", asset)

Create a device, save and read attributes, then delete:

import logging
from tb_rest_client.rest_client_ce import *
from tb_rest_client.rest import ApiException
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(module)s - %(lineno)d - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
url = "http://localhost:8080"
username = "[email protected]"
password = "tenant"
def main():
with RestClientCE(base_url=url) as rest_client:
try:
rest_client.login(username=username, password=password)
default_device_profile_id = rest_client.get_default_device_profile_info().id
device = Device(name="Thermometer 1",
device_profile_id=default_device_profile_id)
device = rest_client.save_device(device)
logging.info("Device was created:\n%r\n", device)
found_device = rest_client.get_device_by_id(DeviceId(device.id, 'DEVICE'))
rest_client.save_device_attributes(DeviceId(device.id, 'DEVICE'), 'SERVER_SCOPE',
import logging
from tb_rest_client.rest_client_ce import *
from tb_rest_client.rest import ApiException
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(module)s - %(lineno)d - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
url = "http://localhost:8080"
username = "[email protected]"
password = "tenant"
def main():
with RestClientCE(base_url=url) as rest_client:
try:
rest_client.login(username=username, password=password)
res = rest_client.get_tenant_devices(page_size=10, page=0)
logging.info("Device info:\n%r", res)
except ApiException as e:
logging.exception(e)
if __name__ == '__main__':
main()
import logging
from tb_rest_client.rest_client_ce import *
from tb_rest_client.rest import ApiException
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(module)s - %(lineno)d - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
url = "http://localhost:8080"
username = "[email protected]"
password = "tenant"
with RestClientCE(base_url=url) as rest_client:
try:
rest_client.login(username=username, password=password)
entity_count_query = EntityCountQuery(
entity_filter=EntityFilter(type='entityType', entity_type='DEVICE'),
key_filters=[KeyFilter(
key={"type": "ATTRIBUTE", "key": "active"},
value_type='BOOLEAN',

For complete examples, see the thingsboard-python-rest-client repository.