A set of Python examples for using the akenza API.
Also refer to the product documentation and the documentation of the REST API.
examples/
├── data
│ ├── data_stream.py Subscribe to the akenza data stream API for a device/set of devices.
│ ├── data_stream_with_tag.py Subscribe to the akenza data stream API with a tag.
│ ├── query_batch.py Query an aggregated KPI for an explicit list of devices.
│ ├── query_data.py Query historical data for a device.
│ ├── query_kpi.py Compute a single aggregated KPI from raw device data.
│ ├── query_latest.py Fetch the most recent data point for a device.
│ ├── query_tag_accumulated_kpi.py Query an accumulated KPI across all devices in a tag group.
│ ├── query_tag_kpi.py Query an aggregated KPI across all devices in a tag group.
│ └── query_time_series.py Retrieve a bucketed time-series using pre-computed hourly aggregates.
├── management
│ ├── get_device.py Retrieve a device by akenza id and device id.
│ ├── get_devices.py Retrieve all devices in a workspace.
│ └── get_tags.py Retrieve all tags in a workspace.
└── uplink
├── coap_discovery.py Discover available CoAP endpoints.
├── coap_dtls_cert_send_data.py Send a CoAP uplink secured with DTLS (ECDSA X.509 certificate).
├── coap_dtls_psk_send_data.py Send a CoAP uplink secured with DTLS (PSK).
├── coap_send_data.py Send a CoAP uplink.
├── http_send_data.py Send an HTTP uplink.
├── http_send_data_sas.py Send an HTTP uplink using Shared Access Signatures.
├── mqtt_receive_downlink.py Subscribe to a downlink topic via MQTT.
├── mqtt_send_data.py Send an MQTT uplink.
├── mqtt_send_data_jwt.py Send an MQTT uplink authenticated with device credentials (JWT).
├── mqtt_send_data_tls.py Send an MQTT uplink using TLS.
└── mqtt_send_receive_jwt.py Send MQTT uplinks and subscribe to downlinks with device
credentials (JWT), refreshing the token on every reconnect.
- Create an api key for your organization
- Retrieve the id of the workspace you want to use
- Retrieve the akenza device id and device id of an existing device in the platform from that workspace (required for getting a device and querying data)
- Create a
.envfile
cp .env.template .env
- Fill in the information
- (optional) Create a new HTTP device (required for sending data via HTTP)
- (optional) Create a new MQTT device (required for sending data via MQTT)
- Install dependencies
uv sync
Run examples from the repository root as Python modules:
uv run python -m examples.data.query_data
uv run python -m examples.management.get_devices
uv run python -m examples.uplink.http_send_data
Python 3.10 or later.