Metadata-Version: 2.4
Name: zentracloud
Version: 0.1.0
Summary: Python SDK for the ZENTRA Cloud v5 API
Project-URL: Homepage, https://gitlab.com/meter-group-inc/pubpackages/zentracloud-py
Project-URL: Source, https://gitlab.com/meter-group-inc/pubpackages/zentracloud-py
Project-URL: Issues, https://gitlab.com/meter-group-inc/pubpackages/zentracloud-py/-/issues
Author-email: Travis Bates <travis@metergroup.com>
License-Expression: MIT
License-File: LICENSE
Keywords: api client,environmental sensors,meter group,zentra,zentracloud
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Requires-Dist: pydantic>=2
Provides-Extra: dev
Requires-Dist: mypy<2,>=1.8; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: respx>=0.20; extra == 'dev'
Requires-Dist: ruff>=0.3; extra == 'dev'
Description-Content-Type: text/markdown

# zentracloud

Python SDK for the [ZENTRA Cloud v5 API](https://docs.zentracloud.io). A typed
client for integrating ZENTRA Cloud device and sensor data into your
application — synchronous and asynchronous, with streaming pagination and
first-class type hints.

## Installation

```bash
pip install zentracloud
```

Requires Python 3.9+.

## Authentication

Get your API key from ZENTRA Cloud: **User Account → Integrations → Show Token**
(<https://app.zentracloud.io/profile/integrations>). Provide it directly or via
the `ZENTRACLOUD_API_KEY` environment variable.

```python
from zentracloud import ZentraClient

client = ZentraClient(api_key="your-api-key")   # or ZentraClient() to read the env var
devices = client.v5.devices.list()
```

## Quickstart (synchronous)

```python
from zentracloud import ZentraClient

with ZentraClient(api_key="your-api-key") as client:
    # Discover devices
    devices = client.v5.devices.list(expand=["max_min_timestamp"])
    for device in devices:
        print(device.device_id, device.name)

    # Stream readings (memory-safe for large pulls)
    for reading in client.v5.devices.iter_data(device_id="z6-00930", start="2026-01-01", end="2026-02-01"):
        print(reading.datetime, reading.measurement, reading.value, reading.error_label)

    # Or collect them all at once
    readings = client.v5.devices.data(device_id="z6-00930", start="2026-01-01")
```

## Quickstart (asynchronous)

```python
import asyncio

from zentracloud import AsyncZentraClient


async def main():
    async with AsyncZentraClient(api_key="your-api-key") as client:
        devices = await client.v5.devices.list()
        async for reading in client.v5.devices.iter_data(device_id="z6-00930", start="2026-01-01"):
            print(reading.datetime, reading.value)


asyncio.run(main())
```

## Time windows

`start` and `end` accept a `datetime`, `date`, epoch seconds (`int`/`float`), or
an ISO-8601 string. Naive datetimes are treated as UTC. Alternatively pass
`start_timestamp` / `end_timestamp` as epoch seconds (not both forms at once).

## Errors

All errors subclass `zentracloud.ZentraError`:
`ZentraAuthError`, `ZentraInvalidRequestError`, `ZentraRateLimitError`,
`ZentraConnectionError`, `ZentraAPIError`. Each carries `.status_code` and
`.detail`.

## Rate limits

The v5 API is limited per key (roughly a 5-request burst, then about one request
per minute). The client paces itself: on HTTP 429 it waits until the API's
next-allowed time and retries automatically (up to `max_retries`).

## License

MIT © METER Group, Inc.
