Metadata-Version: 2.1
Name: osemclient
Version: 0.0.5
Summary: aiohttp-based client for OpenSenseMap API
Project-URL: Changelog, https://github.com/hf-kklein/osem-python-client/releases
Project-URL: Homepage, https://github.com/hf-kklein/osem-python-client
Author-email: your name <your@email.address>
License: MIT
License-File: LICENSE
Keywords: aiohttp,async,opensensemap,osem
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: aiohttp
Requires-Dist: pydantic>=2.0.0
Description-Content-Type: text/markdown

# osem-python-client
`osemclient` is an async Python client with fully typed model classes for the OpenSenseMap REST API.
It is based on aiohttp and Pydantic.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![PyPI status badge](https://img.shields.io/pypi/v/osemclient)
![Python Versions (officially) supported](https://img.shields.io/pypi/pyversions/osemclient.svg)

![Unittests status badge](https://github.com/hf-kklein/osem-python-client/workflows/Unittests/badge.svg)
![Coverage status badge](https://github.com//hf-kklein/osem-python-client/workflows/Coverage/badge.svg)
![Linting status badge](https://github.com/hf-kklein/osem-python-client/workflows/Linting/badge.svg)
![Black status badge](https://github.com/hf-kklein/osem-python-client/workflows/Formatting/badge.svg)


## Usage
```bash
pip install osemclient
```

```python
import asyncio
from typing import Awaitable

from osemclient.client import OpenSenseMapClient
from osemclient.models import Measurement


async def get_recent_measurements(sensebox_id: str):
    client = OpenSenseMapClient()
    box = await client.get_sensebox(sensebox_id)
    sensor_tasks: list[Awaitable[list[Measurement]]] = [
        client.get_sensor_measurements(box.id, sensor.id) for sensor in box.sensors
    ]
    measurement_series = await asyncio.gather(*sensor_tasks)
    await client.close_session()


if __name__ == "__main__":
    asyncio.run(get_recent_measurements(sensebox_id="621f53cdb527de001b06ad5e"))

```

## State of this Project
This project is **very alpha** and more a proof of concept.
It only supports two GET API endpoints as of 2023-12-18 and even those are not covered completely.
If you _really_ want to use it, there's still work to be done but this project might be a good foundation.

## Development
Check the instructions in our [Python Template Repository](https://github.com/Hochfrequenz/python_template_repository#how-to-use-this-repository-on-your-machine).
tl;dr: tox.

## Contribute
You are very welcome to contribute to this template repository by opening a pull request against the main branch.
