Arduino IoT Cloud API Python Client for managing devices, things, properties, and timeseries data
Real-time and historical property data management with timeseries support. Properties represent data points associated with IoT things that can be read, written, and monitored over time.
from iot_api_client.api import (
PropertiesV2Api,
PropertyTypesV1Api
)
from iot_api_client.models import (
ModelProperty,
PropertyValue,
ArduinoProperty,
ArduinoPropertytype,
ArduinoSeriesResponse
)Core property management operations for creating, reading, updating, and deleting thing properties.
class PropertiesV2Api:
def properties_v2_create(self, id: str, model_property: ModelProperty, x_organization: str = None) -> ArduinoProperty:
"""
Creates a property associated to the given thing.
Args:
id: Thing ID
model_property: Property creation payload
x_organization: Organization ID for organization-level access
Returns:
ArduinoProperty: Created property object
"""
def properties_v2_list(self, id: str, show_deleted: bool = None, x_organization: str = None) -> List[ArduinoProperty]:
"""
Returns the list of properties associated to the given thing.
Args:
id: Thing ID
show_deleted: Include deleted properties
x_organization: Organization ID for organization-level access
Returns:
List[ArduinoProperty]: List of property objects
"""
def properties_v2_show(self, id: str, pid: str, show_deleted: bool = None, x_organization: str = None) -> ArduinoProperty:
"""
Returns the property requested by the user.
Args:
id: Thing ID
pid: Property ID
show_deleted: Include deleted properties
x_organization: Organization ID for organization-level access
Returns:
ArduinoProperty: Property object
"""
def properties_v2_update(self, id: str, pid: str, model_property: ModelProperty, x_organization: str = None) -> ArduinoProperty:
"""
Updates a property associated to the given thing.
Args:
id: Thing ID
pid: Property ID
model_property: Property update payload
x_organization: Organization ID for organization-level access
Returns:
ArduinoProperty: Updated property object
"""
def properties_v2_delete(self, id: str, pid: str, force: bool = None, x_organization: str = None) -> None:
"""
Removes a property associated to the given thing.
Args:
id: Thing ID
pid: Property ID
force: Force deletion even if property has data
x_organization: Organization ID for organization-level access
"""Publish real-time values to properties.
class PropertiesV2Api:
def properties_v2_publish(self, id: str, pid: str, property_value: PropertyValue, x_organization: str = None) -> None:
"""
Publish a property value to Arduino IoT Cloud.
Args:
id: Thing ID
pid: Property ID
property_value: Value to publish
x_organization: Organization ID for organization-level access
"""Retrieve historical property data with flexible time ranges and aggregation options.
class PropertiesV2Api:
def properties_v2_timeseries(self, id: str, pid: str, desc: bool = None, start: str = None, end: str = None, interval: int = None, x_organization: str = None) -> ArduinoSeriesResponse:
"""
Get property timeseries data.
Args:
id: Thing ID
pid: Property ID
desc: Sort results in descending order
start: Start timestamp (RFC3339 format)
end: End timestamp (RFC3339 format)
interval: Aggregation interval in seconds
x_organization: Organization ID for organization-level access
Returns:
ArduinoSeriesResponse: Timeseries data
"""Discover available property types for creating properties.
class PropertyTypesV1Api:
def property_types_v1_list_types(self) -> List[ArduinoPropertytype]:
"""
Returns the list of available property types.
Returns:
List[ArduinoPropertytype]: Available property types
"""from iot_api_client.models import ModelProperty
# Create a temperature property
temperature_property = ModelProperty(
name="temperature",
type="FLOAT",
permission="READ_WRITE",
variable_name="temp",
persist=True,
tag=1,
update_strategy="ON_CHANGE",
min_delta=0.1
)
property_obj = properties_api.properties_v2_create("thing-id", temperature_property)
print(f"Created property: {property_obj.name} (ID: {property_obj.id})")from iot_api_client.models import PropertyValue
from datetime import datetime
# Publish a temperature reading
value = PropertyValue(
value=23.5,
created_at=datetime.utcnow()
)
properties_api.properties_v2_publish("thing-id", "property-id", value)from datetime import datetime, timedelta
# Get last 24 hours of data with 1-hour intervals
end_time = datetime.utcnow()
start_time = end_time - timedelta(days=1)
timeseries = properties_api.properties_v2_timeseries(
"thing-id",
"property-id",
start=start_time.isoformat() + "Z",
end=end_time.isoformat() + "Z",
interval=3600 # 1 hour in seconds
)
for data_point in timeseries.data:
print(f"Time: {data_point.timestamp}, Value: {data_point.value}")# List all available property types
property_types = property_types_api.property_types_v1_list_types()
for prop_type in property_types:
print(f"Type: {prop_type.type}, Description: {prop_type.description}")class ModelProperty:
max_value: float
min_value: float
name: str
permission: str # "READ", "WRITE", "READ_WRITE"
persist: bool
tag: int
type: str # Property type (FLOAT, INT, BOOL, STRING, etc.)
update_parameter: float
update_strategy: str # "ON_CHANGE", "TIMED"
variable_name: str
min_delta: float
class PropertyValue:
value: Any
created_at: datetime
class ArduinoProperty:
created_at: datetime
deleted_at: datetime
href: str
id: str
last_value: Any
linked_variables: List[ArduinoLinkedvariable]
max_value: float
min_value: float
name: str
persist: bool
permission: str
tag: int
thing_id: str
type: str
update_parameter: float
update_strategy: str
updated_at: datetime
variable_name: str
class ArduinoPropertytype:
type: str
description: str
class ArduinoSeriesResponse:
count_values: int
data: List[TimeseriesDataPoint]
from_date: datetime
interval: int
message: str
query: str
resp_version: int
series_limit: int
sort: str
status: str
times: List[str]
to_date: datetime
values: List[Any]
class TimeseriesDataPoint:
timestamp: str
value: AnyInstall with Tessl CLI
npx tessl i tessl/pypi-arduino-iot-client