aiohttp-based client for OpenSenseMap API
Project description
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.
Usage
pip install osemclient
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. tl;dr: tox.
Contribute
You are very welcome to contribute to this template repository by opening a pull request against the main branch.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
osemclient-0.0.5.tar.gz
(12.8 kB
view hashes)
Built Distribution
Close
Hashes for osemclient-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a40d089280833a0b93224cfe38801a42e3ae1f45cacdbc13b0c38bc5beb51251 |
|
MD5 | 9228e808da53bc4edd47dfa9c60c5a4f |
|
BLAKE2b-256 | bc85eaecfc9b5f9b2ebc7701fbb327a65965279bd99831ebd19b67a5745115de |