Asynchronous client for MeteoSwiss API.
Project description
Python Async API Client
This have in mind to start developing API clients for Home Assistant to be 100% asynchronous
How to Use it?
Fork this repository by using it as a template.
Structure
This package provides good defaults for any API client code that is split on the following modules:
errors.py
: module that define the custom errors the API and/or client would be returning to their users.model.py
: definition of the API data model. All returned objects from the clients would be defined here.client.py
: the logic around calling the API
Development
To start developing with this package, fork it, create a virtual environment and install all the dependencies needed for development.
python3 -m venv .venv
source .venv/bin/activate
pip install '.[dev]'
Best Practices
This package provides already an skeleton with some best practices when starting developing your API client.
- 100% async from the start: Home Assistant runs its main logic using an asynchronous engine, and having 3rd party clients running async can have performance benefits and ease of integration on new and existing components.
- A
aiohttp.ClientSession
should always to be a constructor argument (so a session and connection pool can be shared between multiple clients). The template already provides a class constructor to create the Client without any initialClientSession
in case it is not available. - The output of each API endpoint is a typed
Model
that is build as a dataclass and can be parsed from a JSON response or a nested dictionary. This ensures the consumer of the API outputs can take benefits from the benefits dataclasses provide like readaibility on its structure and field types. - The whole library is annotated with Python types so type checkers can help us detect errors early on rather than at runtime.
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
Built Distribution
Close
Hashes for meteoswiss_async-0.1.0rc41.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bafc27dc3053c67556d33e855edbdf711c93ccda635ac319577e3b8d1c624c8b |
|
MD5 | 6fa9b022d4fadaf5f483328a3b0ae2d7 |
|
BLAKE2b-256 | 4b6a59b30571739309c3b8b5776e548fbe3ac4ff3335aa1581b89e99bdc21b16 |
Close
Hashes for meteoswiss_async-0.1.0rc41.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68fd89aba0ac96727d1adbb6a3ac191954d0b5d15f81f6e64a269f01b6639b2a |
|
MD5 | 85e2d91099bc7c96e1baf9a54242c5c7 |
|
BLAKE2b-256 | 88f953e0205e4300c09d8849c2d6b6482349a561678d6dd9a444965b671403c3 |