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
).
pip install consentiumthings
from consentiumthings import ConsentiumThings
You need to provide your board key when creating a new instance:
ct = ConsentiumThings("YOUR-BOARD-KEY")
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"
}
To fetch data, initialize with your receive key, then call receive_data()
.
- By default, it fetches the most recent data.
- Set
recent=False
to 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
}
]
Initialize the client.
-
Parameters:
board_key
(str): Unique key for your board.
Set up the client for sending data.
-
Parameters:
send_key
(str): The key for authenticated send operations.
Send sensor data.
-
Parameters:
data_buff
(list): List of sensor values.info_buff
(list): Labels for each sensor value.
-
Returns: Dict containing API response.
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.
Fetch data from the cloud.
- Returns: List of dicts with parsed sensor data.
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())
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 |
For any issues or questions regarding ConsentiumThings Python API, please contact [email protected].
This software is licensed under the MIT License. See the LICENSE file for details.