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.1.tar.gz
(4.8 kB
view details)
Built Distribution
File details
Details for the file pyemoncms-0.1.1.tar.gz
.
File metadata
- Download URL: pyemoncms-0.1.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fbcc839b9ff3ba65391c71db813c8f72b84d834fcbcadd805cad8d123e1854d |
|
MD5 | 0e373f1c56b6628bd226783b79bb45d1 |
|
BLAKE2b-256 | 5826676c37667153be906518fe261ef45e8e213d59e06d6a24a1f4677a669935 |
File details
Details for the file pyemoncms-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pyemoncms-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f99d23d13d7c6f149da54717630388945eb9e69f29425bec90e4b5771ffb86b |
|
MD5 | 65e1217aececb2fcaa1f99b6af2eb2ff |
|
BLAKE2b-256 | a393c66086cccc9c3fdf1c06a8d1a68d20f27450bad5277ae0081bbbc773bd16 |