Skip to main content

patera-apiinterface

Declarative async HTTP clients for external APIs in Patera applications. Part of Patera, a modular async-first Python web framework.

Installation

pip install patera-apiinterface
# or, with uv
uv add "patera[apiinterface]"

Requires Python 3.13 or newer and patera>=0.121.

Usage

Within an application lifespan, an interface reuses one HTTP client and closes it at shutdown. Standalone and CLI endpoint calls use temporary clients closed before the call returns, including failures. If you acquire interface.client explicitly, call await interface.aclose() in that same event loop before it closes. Access from another loop raises instead of discarding an unclosed client.

patera-apiinterface turns annotated methods into HTTP calls (with HTTPX):

from patera import HttpMethod
from patera.apiinterface import ApiInterface, AuthType, auth, headers, method, resource, service, timeout


@service("GITHUB_URL")                         # config key or literal URL
@auth(AuthType.BEARER, token="GITHUB_TOKEN")   # config key or literal value
@headers({"X-Client": "my-app"})
@timeout(10)
class GithubApi(ApiInterface):

    @method(HttpMethod.GET)
    @resource("/repos/<repo_id>")              # filled from the argument of the same name
    async def get_repo(self, repo_id: int) -> Repo: ...   # Pydantic return types are validated

    @method(HttpMethod.POST)
    @resource("/repos")
    async def create_repo(self, name: str, private: bool) -> dict: ...   # arguments become the JSON body

See the External APIs section of the Patera documentation for the full guide.

License

MIT. See LICENSE.

Metadata

Release files for patera-apiinterface 0.13.2

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

Source distribution (sdist)

Source distribution for patera-apiinterface 0.13.2
File Size Uploaded Provenance Actions
patera_apiinterface-0.13.2.tar.gz 10.3 kB Without provenance Details for patera_apiinterface-0.13.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for patera-apiinterface 0.13.2
File Interpreter ABI Platform Actions
patera_apiinterface-0.13.2-py3-none-any.whl Python 3 none any Details for patera_apiinterface-0.13.2-py3-none-any.whl

Total release size: 22.0 kB

Release files / patera_apiinterface-0.13.2.tar.gz

Download URL patera_apiinterface-0.13.2.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1f0d8d687c898ec5adcaf07b4c975ab7ad51291f01a10d94c6c41a66505b074b
BLAKE2b-256 checksum
How to use checksums
57f0080f67a3a967280d623ab9c082591fa280125f24382b7d39db9b0403d805
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / patera_apiinterface-0.13.2-py3-none-any.whl

Download URL patera_apiinterface-0.13.2-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be1f189a26832a6fb5b08a68f8e5231d81871c31f30c9c16a7d705b4571d5ce1
BLAKE2b-256 checksum
How to use checksums
2274a2012208dddff38a24215ad86a2ac8a80ace91c03cc47f105b930983c4bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for patera-apiinterface 0.13.2

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.

Release history Release notifications | RSS feed

This release

0.13.2 This release

2 release files No provenance

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