Skip to main content

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

logging.basicConfig()
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())

error handling

By default, failures are returned as {"success": False, "message": "..."} (or None from the helpers). Pass raise_errors=True to get exceptions instead :

from pyemoncms import EmoncmsAuthError, EmoncmsClient, EmoncmsConnectionError, EmoncmsError

client = EmoncmsClient(url, key, raise_errors=True)
try:
    feeds = await client.async_list_feeds()
except EmoncmsAuthError:
    ...  # invalid API key (HTTP 401)
except EmoncmsConnectionError:
    ...  # timeout or server unreachable
except EmoncmsError:
    ...  # any other error response

Metadata

Release files for pyemoncms 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyemoncms 0.1.4
File Size Uploaded Provenance Actions
pyemoncms-0.1.4.tar.gz 6.4 kB Without provenance Details for pyemoncms-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyemoncms 0.1.4
File Interpreter ABI Platform Actions
pyemoncms-0.1.4-py3-none-any.whl Python 3 none any Details for pyemoncms-0.1.4-py3-none-any.whl

Total release size: 12.0 kB

Release files / pyemoncms-0.1.4.tar.gz

Download URL pyemoncms-0.1.4.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0efddd4ad0dff21fbf7f086e49885adf70d2626d8e060a653b69d5bbaa69d47b
BLAKE2b-256 checksum
How to use checksums
55ec8e62d334614b20342f3cb68efae352ca594ab882a123dfb6df28397d4556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / pyemoncms-0.1.4-py3-none-any.whl

Download URL pyemoncms-0.1.4-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a81149e196217068114c925dbda0efac7b4b61bc499139c99c03818eb04514a
BLAKE2b-256 checksum
How to use checksums
1cc2a332e2f2ad62ac302fed30483282633682e11dfcc2b43355c561c8c76903
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for pyemoncms 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page