Skip to main content

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.

License: MIT PyPI status badge Python Versions (officially) supported

Unittests status badge Coverage status badge Linting status badge Black status badge

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)

Uploaded Source

Built Distribution

osemclient-0.0.5-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page