CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-arduino-iot-client

Arduino IoT Cloud API Python Client for managing devices, things, properties, and timeseries data

Overview
Eval results
Files

series.mddocs/

Timeseries Data

Advanced querying capabilities for timeseries data with batch operations, historical data access, raw and sampled data retrieval for comprehensive IoT analytics.

Core Imports

from iot_api_client.api import SeriesV2Api
from iot_api_client.models import (
    BatchQueryRawRequestsMediaV1,
    BatchQuerySampledRequestsMediaV1,
    BatchLastValueRequestsMediaV1,
    HistoricDataRequest,
    ArduinoSeriesRawResponse,
    ArduinoSeriesSampledResponse,
    ArduinoSeriesRawLastValueResponse,
    ArduinoSeriesResponse
)

Capabilities

Batch Raw Data Queries

Retrieve raw timeseries data for multiple properties in a single request.

class SeriesV2Api:
    def series_v2_batch_query_raw(self, batch_query_raw_requests_media_v1: BatchQueryRawRequestsMediaV1, x_organization: str = None) -> ArduinoSeriesRawResponse:
        """
        Batch query raw timeseries data for multiple properties.

        Args:
            batch_query_raw_requests_media_v1: Batch query configuration for raw data
            x_organization: Organization ID for organization-level access

        Returns:
            ArduinoSeriesRawResponse: Raw timeseries data response
        """

Batch Sampled Data Queries

Retrieve aggregated/sampled timeseries data for multiple properties.

class SeriesV2Api:
    def series_v2_batch_query_sampling(self, batch_query_sampled_requests_media_v1: BatchQuerySampledRequestsMediaV1, x_organization: str = None) -> ArduinoSeriesSampledResponse:
        """
        Batch query sampled timeseries data for multiple properties.

        Args:
            batch_query_sampled_requests_media_v1: Batch query configuration for sampled data
            x_organization: Organization ID for organization-level access

        Returns:
            ArduinoSeriesSampledResponse: Sampled timeseries data response
        """

Batch Last Value Queries

Get the most recent values for multiple properties efficiently.

class SeriesV2Api:
    def series_v2_batch_query_raw_last_value(self, batch_last_value_requests_media_v1: BatchLastValueRequestsMediaV1, x_organization: str = None) -> ArduinoSeriesRawLastValueResponse:
        """
        Batch query for the last value of multiple properties.

        Args:
            batch_last_value_requests_media_v1: Batch last value query configuration
            x_organization: Organization ID for organization-level access

        Returns:
            ArduinoSeriesRawLastValueResponse: Last values response
        """

Historic Data Requests

Access archived historical data with advanced filtering options.

class SeriesV2Api:
    def series_v2_historic_data(self, historic_data_request: HistoricDataRequest, x_organization: str = None) -> ArduinoSeriesResponse:
        """
        Request historic data for properties.

        Args:
            historic_data_request: Historic data request configuration
            x_organization: Organization ID for organization-level access

        Returns:
            ArduinoSeriesResponse: Historic data response
        """

Usage Examples

Batch Query Raw Data

from iot_api_client.models import (
    BatchQueryRawRequestsMediaV1,
    BatchQueryRawRequestMediaV1
)
from datetime import datetime, timedelta

# Query raw data for multiple properties
end_time = datetime.utcnow()
start_time = end_time - timedelta(hours=24)

raw_request = BatchQueryRawRequestMediaV1(
    thing_id="thing-id",
    property_id="temperature-property-id",
    from_date=start_time.isoformat() + "Z",
    to_date=end_time.isoformat() + "Z"
)

batch_request = BatchQueryRawRequestsMediaV1(
    requests=[raw_request]
)

raw_response = series_api.series_v2_batch_query_raw(batch_request)

for series in raw_response.data:
    print(f"Property: {series.property_id}")
    for point in series.values:
        print(f"  Time: {point.timestamp}, Value: {point.value}")

Batch Query Sampled Data

from iot_api_client.models import (
    BatchQuerySampledRequestsMediaV1,
    BatchQuerySampledRequestMediaV1
)

# Query sampled data with 1-hour intervals
sampled_request = BatchQuerySampledRequestMediaV1(
    thing_id="thing-id",
    property_id="temperature-property-id",
    from_date=start_time.isoformat() + "Z",
    to_date=end_time.isoformat() + "Z",
    interval=3600,  # 1 hour in seconds
    aggregation="AVG"  # Average aggregation
)

batch_sampled_request = BatchQuerySampledRequestsMediaV1(
    requests=[sampled_request]
)

sampled_response = series_api.series_v2_batch_query_sampling(batch_sampled_request)

for series in sampled_response.data:
    print(f"Property: {series.property_id}")
    for point in series.values:
        print(f"  Time: {point.timestamp}, Avg Value: {point.value}")

Get Last Values

from iot_api_client.models import (
    BatchLastValueRequestsMediaV1,
    BatchQueryRawLastValueRequestMediaV1
)

# Get last values for multiple properties
last_value_request = BatchQueryRawLastValueRequestMediaV1(
    thing_id="thing-id",
    property_ids=["temperature-id", "humidity-id", "pressure-id"]
)

batch_last_value_request = BatchLastValueRequestsMediaV1(
    requests=[last_value_request]
)

last_values_response = series_api.series_v2_batch_query_raw_last_value(batch_last_value_request)

for series in last_values_response.data:
    if series.last_value:
        print(f"Property {series.property_id}: {series.last_value.value} at {series.last_value.timestamp}")

Historic Data Query

from iot_api_client.models import HistoricDataRequest

# Request historic data with specific criteria
historic_request = HistoricDataRequest(
    thing_id="thing-id",
    property_id="sensor-property-id",
    from_date="2024-01-01T00:00:00Z",
    to_date="2024-01-31T23:59:59Z",
    sort="DESC",
    interval=86400  # Daily aggregation
)

historic_response = series_api.series_v2_historic_data(historic_request)

print(f"Retrieved {len(historic_response.values)} data points")
for i, (timestamp, value) in enumerate(zip(historic_response.times, historic_response.values)):
    print(f"  {timestamp}: {value}")

Types

class BatchQueryRawRequestsMediaV1:
    requests: List[BatchQueryRawRequestMediaV1]

class BatchQueryRawRequestMediaV1:
    thing_id: str
    property_id: str
    from_date: str
    to_date: str
    sort: str  # "ASC" or "DESC"
    limit: int

class BatchQuerySampledRequestsMediaV1:
    requests: List[BatchQuerySampledRequestMediaV1]

class BatchQuerySampledRequestMediaV1:
    thing_id: str
    property_id: str
    from_date: str
    to_date: str
    interval: int
    aggregation: str  # "AVG", "MIN", "MAX", "SUM", "COUNT"
    sort: str

class BatchLastValueRequestsMediaV1:
    requests: List[BatchQueryRawLastValueRequestMediaV1]

class BatchQueryRawLastValueRequestMediaV1:
    thing_id: str
    property_ids: List[str]

class HistoricDataRequest:
    thing_id: str
    property_id: str
    from_date: str
    to_date: str
    sort: str
    interval: int

class ArduinoSeriesRawResponse:
    count_values: int
    data: List[BatchQueryRawResponseSeriesMediaV1]
    from_date: str
    interval: int
    message: str
    query: str
    resp_version: int
    series_limit: int
    sort: str
    status: str
    to_date: str

class ArduinoSeriesSampledResponse:
    count_values: int
    data: List[ArduinoSeriesBatchSampled]
    from_date: str
    interval: int
    message: str
    query: str
    resp_version: int
    series_limit: int
    sort: str
    status: str
    to_date: str

class ArduinoSeriesRawLastValueResponse:
    data: List[ArduinoSeriesRawBatchLastvalue]
    message: str
    query: str
    resp_version: int
    status: 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]

Install with Tessl CLI

npx tessl i tessl/pypi-arduino-iot-client

docs

dashboards.md

devices.md

index.md

lora.md

properties.md

series.md

things.md

tile.json