Python lib for sending sensor data to Consentium IoT server.
Project description
ConsentiumThings Python API
Overview
ConsentiumThings is a Python library for sending and receiving IoT data from the Consentium Cloud. It provides an easy-to-use interface to interact with the Consentium IoT APIs, including sensor data ingestion (/v2/updateData) and retrieval (/getData).
Installation
pip install consentiumthings
Usage
Importing ConsentiumThings
from consentiumthings import ConsentiumThings
Initializing ConsentiumThings
You need to provide your board key when creating a new instance:
ct = ConsentiumThings("YOUR-BOARD-KEY")
Sending Data
To send data, initialize with your send key, then call send_data():
ct.begin_send("YOUR-SEND-KEY")
response = ct.send_data(
data_buff=[40.0, 90.0],
info_buff=["Temperature", "Humidity"]
)
print(response)
Example response (success):
{
"status": "success",
"message": "Sensor data updated successfully"
}
Example response (MAC mismatch):
{
"message": "MAC mismatch"
}
Receiving Data
To fetch data, initialize with your receive key, then call receive_data().
- By default, it fetches the most recent data.
- Set
recent=Falseto fetch the full history.
ct.begin_receive("YOUR-RECEIVE-KEY", recent=True)
data = ct.receive_data()
print(data)
Example response (parsed into Python dicts):
[
{
"updated_at": "2025-09-05T14:20:56Z",
"Temperature": 40.0,
"Humidity": 90.0
}
]
Methods
ConsentiumThings(board_key)
Initialize the client.
-
Parameters:
board_key(str): Unique key for your board.
begin_send(send_key)
Set up the client for sending data.
-
Parameters:
send_key(str): The key for authenticated send operations.
send_data(data_buff, info_buff)
Send sensor data.
-
Parameters:
data_buff(list): List of sensor values.info_buff(list): Labels for each sensor value.
-
Returns: Dict containing API response.
begin_receive(receive_key, recent=True)
Set up the client for retrieving data.
-
Parameters:
receive_key(str): Key for authenticated receive operations.recent(bool): If True, fetch only most recent entry. Default: True.
receive_data()
Fetch data from the cloud.
- Returns: List of dicts with parsed sensor data.
Example
from consentiumthings import ConsentiumThings
# Initialize client
ct = ConsentiumThings("YOUR-BOARD-KEY")
# Send data
ct.begin_send("YOUR-SEND-KEY")
print(ct.send_data([40.0, 90.0], ["Temperature", "Humidity"]))
# Receive most recent data
ct.begin_receive("YOUR-RECEIVE-KEY", recent=True)
print(ct.receive_data())
Error Handling
The API may return structured JSON errors. Common cases:
| Code | Example Response | Meaning |
|---|---|---|
200 |
{"status":"success"} |
Data sent/received successfully |
422 |
{"message":"MAC mismatch"} |
MAC address does not match registered board |
401 |
{"message":"Invalid key"} |
Send/receive key invalid |
404 |
{"message":"Board not found"} |
Board key is invalid |
Support
For any issues or questions regarding ConsentiumThings Python API, please contact official@consentiumiot.com.
License
This software is licensed under the MIT License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file consentiumthings-1.0.1.tar.gz.
File metadata
- Download URL: consentiumthings-1.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc41e9864a20911cc2c26cff598f33a765aca35eefc72d35470153bd093113e9
|
|
| MD5 |
13212a327e4ca3f173cbb1c6286fcb41
|
|
| BLAKE2b-256 |
ac422bd52343943346d73e37fb9799e11f4cbdd3b7ec0e2f42b8bd32897f65e2
|
File details
Details for the file consentiumthings-1.0.1-py3-none-any.whl.
File metadata
- Download URL: consentiumthings-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56b8f0f3ceb4bcfa8118dcbb3102af59a646cd4d52dbc4ed9e12dff24ce054e4
|
|
| MD5 |
2ed299e2e1687056a879da0601e0768b
|
|
| BLAKE2b-256 |
283ffee5fe8a172452b44e0c1b57cc6336412899e5c9e0e516d10dca3ecf83e9
|