A python library to interrogate emoncms API
Project description
pyemoncms
python library for emoncms API
rely on aiohttp
to install : pip3 install pyemoncms
how to use :
import logging
import asyncio
from pyemoncms import EmoncmsClient
key = "your32bitsAPIkey"
url = "http://url:8081"
client = EmoncmsClient(url, key, request_timeout=1)
client.logger.setLevel("DEBUG")
async def get_path(path):
print(await client.async_request(path))
async def list_feeds():
print(await client.async_list_feeds())
async def get_feed_fields(feed_id):
print(await client.async_get_feed_fields(feed_id))
loop = asyncio.get_event_loop()
loop.create_task(get_path("feed/list.json"))
loop.create_task(get_path("/user/getuuid.json"))
loop.create_task(list_feeds())
loop.create_task(get_feed_fields(1))
try:
loop.run_forever()
except Exception:
client.logger.error("something happened")
finally:
loop.run_until_complete(client.close())
loop.close()
even simpler with a context manager :
async def main():
"""fetches somes datas in emoncms"""
async with EmoncmsClient(url, key, request_timeout=1) as client:
client.logger.setLevel("DEBUG")
print(await client.async_get_uuid())
print(await client.async_list_feeds())
print(await client.async_get_feed_fields(1))
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyemoncms-0.1.2.tar.gz
(5.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyemoncms-0.1.2.tar.gz.
File metadata
- Download URL: pyemoncms-0.1.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05c4595dbeab155262ccccc1089ef08dd39b61dd7c325e4abade8726d77e69f8
|
|
| MD5 |
a0783aa98153129a2dd31914e1bfd1bc
|
|
| BLAKE2b-256 |
45e99ac1d6b58ff745fcf2e146e9b2e5234fb8c4ef2f7acff6c09b3b0eb22ac7
|
File details
Details for the file pyemoncms-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pyemoncms-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05f7d0bd982583fda89dd19f7580597b4f3293194b24862f1b8046c090fe9deb
|
|
| MD5 |
f2428507818edea578ac248bfd52321d
|
|
| BLAKE2b-256 |
aafd4c28ce3b731feae3935ef14d259418c398843733148f74ddb4d8ada68b24
|