Metadata-Version: 2.4
Name: scadable
Version: 2.0.1
Summary: Official Python SDK for the Scadable IoT platform.
Author: Scadable
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/scadable/library-python
Project-URL: Bug Tracker, https://github.com/scadable/library-python/issues
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.0
Requires-Dist: websockets>=13.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: respx; extra == "dev"
Requires-Dist: coverage; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Dynamic: license-file

# Scadable Python SDK

[![PyPi](https://img.shields.io/pypi/v/scadable)](https://pypi.org/project/scadable/)
[![Downloads](https://static.pepy.tech/badge/scadable/month)](https://pepy.tech/project/scadable)
[![Supported Versions](https://img.shields.io/pypi/pyversions/scadable.svg)](https://pypi.org/project/scadable)
[![GitHub actions status](https://github.com/scadable/library-python/actions/workflows/test-project.yml/badge.svg)](https://github.com/scadable/library-python/actions/workflows/test-project.yml)

The official Python SDK for the [Scadable](https://scadable.com) IoT platform. Check gateway status, list devices, and stream live telemetry in 3 lines of code.

## Install

```bash
pip install scadable
```

## Quick Start

```python
from scadable import Scadable

client = Scadable(api_key="sk_live_...")

# List gateways
for gw in client.gateways.list():
    print(f"{gw.name}: {gw.status}")

# Get gateway detail
gw = client.gateways.get("gateway-id")
print(gw.name, gw.status)

# List devices on a gateway
for device in client.gateways.devices("gateway-id"):
    print(f"{device.name} [{device.status}]")
```

## Stream Live Telemetry

```python
import asyncio
from scadable import AsyncScadable

async def main():
    client = AsyncScadable(api_key="sk_live_...")

    async with client.gateways.stream("gateway-id") as stream:
        async for event in stream:
            print(event.type, event.data)

asyncio.run(main())
```

## Authentication

Pass your API key directly or set it as an environment variable:

```python
# Direct
client = Scadable(api_key="sk_live_...")

# Environment variable
# export SCADABLE_API_KEY=sk_live_...
client = Scadable()
```

API keys are created in the [Scadable Dashboard](https://dashboard.scadable.com) under project settings.

## Error Handling

```python
from scadable import Scadable, AuthenticationError, NotFoundError

client = Scadable(api_key="sk_live_...")

try:
    gw = client.gateways.get("bad-id")
except NotFoundError:
    print("Gateway not found")
except AuthenticationError:
    print("Invalid API key")
```

## Requirements

- Python 3.10+
- Dependencies: `httpx`, `pydantic`, `websockets`

## License

Apache 2.0
