Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.

  1. 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.
  2. 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 initial ClientSession in case it is not available.
  3. 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.
  4. The whole library is annotated with Python types so type checkers can help us detect errors early on rather than at runtime.

Release files for project-async 0.0.1rc105.post1

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

Source distribution (sdist)

Source distribution for project-async 0.0.1rc105.post1
File Size Uploaded
project_async-0.0.1rc105.post1.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for project-async 0.0.1rc105.post1
File Interpreter ABI Platform
project_async-0.0.1rc105.post1-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / project_async-0.0.1rc105.post1.tar.gz

Download URL project_async-0.0.1rc105.post1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e0298d8c7faf61e991067ac69ef1d7d43ded035c256a00199efce8fdf3ccbb0c
BLAKE2b-256 checksum
How to use checksums
2706924cd9284a82bc0f37ef51a8eceaaebcbcfc05b30493ad20a9a9304317c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / project_async-0.0.1rc105.post1-py3-none-any.whl

Download URL project_async-0.0.1rc105.post1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4354e2a927c3c74a404f34b9e7e1c31a202274ff380545925281c49df10f89a1
BLAKE2b-256 checksum
How to use checksums
b91c4ce7d7e88154bd8846729fd3f110232adc2f54ff5e6f0c7ab3d3dcdac67f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3
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