Name | osemclient JSON |
Version |
0.1.2
JSON |
| download |
home_page | |
Summary | aiohttp-based client for OpenSenseMap API |
upload_time | 2023-12-22 12:09:46 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.11 |
license | MIT |
keywords |
aiohttp
async
opensensemap
osem
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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 osemclient.client import OpenSenseMapClient
async def get_recent_measurements(sensebox_id: str):
"""
downloads the latest 10_000 measurements for the given sensebox id
"""
client = OpenSenseMapClient()
try:
measurements = [x async for x in client.get_measurements_with_sensor_metadata(sensebox_id=sensebox_id)]
print(
f"There are {len(measurements)} measurements available: "
+ ", ".join(str(ms) for ms in measurements[0:3])
+ " ..."
)
assert any(m for m in measurements if m.unit == "°C") # there are temperature measurements
assert any(m for m in measurements if m.unit == "hPa") # there are air pressure measurements
# and many more
finally:
await client.close_session()
if __name__ == "__main__":
asyncio.run(get_recent_measurements(sensebox_id="621f53cdb527de001b06ad5e"))
```
Methods that return measurement values are async generators.
This allows for kind of streaming the data from the OSeM API and avoids large bloating lists in memory.
## 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.
Raw data
{
"_id": null,
"home_page": "",
"name": "osemclient",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "",
"keywords": "aiohttp,async,opensensemap,osem",
"author": "",
"author_email": "your name <your@email.address>",
"download_url": "https://files.pythonhosted.org/packages/12/b0/62f914751010eec28648f89ee5fd5be301137982b6b42395456e1a411ee4/osemclient-0.1.2.tar.gz",
"platform": null,
"description": "# osem-python-client\n`osemclient` is an async Python client with fully typed model classes for the OpenSenseMap REST API.\nIt is based on aiohttp and Pydantic.\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![PyPI status badge](https://img.shields.io/pypi/v/osemclient)\n![Python Versions (officially) supported](https://img.shields.io/pypi/pyversions/osemclient.svg)\n\n![Unittests status badge](https://github.com/hf-kklein/osem-python-client/workflows/Unittests/badge.svg)\n![Coverage status badge](https://github.com//hf-kklein/osem-python-client/workflows/Coverage/badge.svg)\n![Linting status badge](https://github.com/hf-kklein/osem-python-client/workflows/Linting/badge.svg)\n![Black status badge](https://github.com/hf-kklein/osem-python-client/workflows/Formatting/badge.svg)\n\n\n## Usage\n```bash\npip install osemclient\n```\n\n```python\nimport asyncio\nfrom osemclient.client import OpenSenseMapClient\n\n\nasync def get_recent_measurements(sensebox_id: str):\n \"\"\"\n downloads the latest 10_000 measurements for the given sensebox id\n \"\"\"\n client = OpenSenseMapClient()\n try:\n measurements = [x async for x in client.get_measurements_with_sensor_metadata(sensebox_id=sensebox_id)]\n print(\n f\"There are {len(measurements)} measurements available: \"\n + \", \".join(str(ms) for ms in measurements[0:3])\n + \" ...\"\n )\n assert any(m for m in measurements if m.unit == \"\u00b0C\") # there are temperature measurements\n assert any(m for m in measurements if m.unit == \"hPa\") # there are air pressure measurements\n # and many more\n finally:\n await client.close_session()\n\n\nif __name__ == \"__main__\":\n asyncio.run(get_recent_measurements(sensebox_id=\"621f53cdb527de001b06ad5e\"))\n\n```\nMethods that return measurement values are async generators.\nThis allows for kind of streaming the data from the OSeM API and avoids large bloating lists in memory.\n\n## State of this Project\nThis project is **very alpha** and more a proof of concept.\nIt only supports two GET API endpoints as of 2023-12-18 and even those are not covered completely.\nIf you _really_ want to use it, there's still work to be done but this project might be a good foundation.\n\n## Development\nCheck the instructions in our [Python Template Repository](https://github.com/Hochfrequenz/python_template_repository#how-to-use-this-repository-on-your-machine).\ntl;dr: tox.\n\n## Contribute\nYou are very welcome to contribute to this template repository by opening a pull request against the main branch.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "aiohttp-based client for OpenSenseMap API",
"version": "0.1.2",
"project_urls": {
"Changelog": "https://github.com/hf-kklein/osem-python-client/releases",
"Homepage": "https://github.com/hf-kklein/osem-python-client"
},
"split_keywords": [
"aiohttp",
"async",
"opensensemap",
"osem"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1b74861dc4a486dd2be054161ed30db0a4850f1e9c9d7d50fceac0e2f7d5a85e",
"md5": "3e91abcfa2cb220fe2786b5542b650c4",
"sha256": "2fe1d8440e6cf2f916c0e55f964466f586586f32542472bdb282f7274756e1ca"
},
"downloads": -1,
"filename": "osemclient-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3e91abcfa2cb220fe2786b5542b650c4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 10791,
"upload_time": "2023-12-22T12:09:45",
"upload_time_iso_8601": "2023-12-22T12:09:45.326563Z",
"url": "https://files.pythonhosted.org/packages/1b/74/861dc4a486dd2be054161ed30db0a4850f1e9c9d7d50fceac0e2f7d5a85e/osemclient-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "12b062f914751010eec28648f89ee5fd5be301137982b6b42395456e1a411ee4",
"md5": "4909173d1cec42e05a9651f66dc4b58b",
"sha256": "b17c3debb6e7d5999f8a72b959d56b8cd4c1fd67df99fc9a49ad06a91f61c358"
},
"downloads": -1,
"filename": "osemclient-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "4909173d1cec42e05a9651f66dc4b58b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 16287,
"upload_time": "2023-12-22T12:09:46",
"upload_time_iso_8601": "2023-12-22T12:09:46.681312Z",
"url": "https://files.pythonhosted.org/packages/12/b0/62f914751010eec28648f89ee5fd5be301137982b6b42395456e1a411ee4/osemclient-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-22 12:09:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hf-kklein",
"github_project": "osem-python-client",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "osemclient"
}