Declarative HTTP clients for the Pico ecosystem: @http_client classes with @get/@post stubs over httpx.
Project description
pico-httpx
Declarative HTTP clients for the pico ecosystem: write the interface, get the implementation. Powered by httpx.
Installation
pip install pico-httpx
Quick start
import httpx
from pico_httpx import http_client, get, post
@http_client(base_url="https://api.example.com") # or resolve from config, see below
class UsersApi:
@get("/users/{user_id}")
def get_user(self, user_id: int, verbose: bool | None = None) -> dict: ...
@post("/users")
async def create_user(self, json: dict) -> dict: ...
@get("/users/{user_id}/avatar")
def avatar(self, user_id: int) -> httpx.Response: ...
The class is a regular @component — inject it anywhere. Rules:
{placeholders}in the path bind to method parameters.- A parameter named
jsonis the request body. - Every other parameter becomes a query param (
Nonevalues are dropped). - Return annotation
httpx.Responsegets the raw response; anything else getsresponse.json()(orNoneon an empty body). Non-2xx raiseshttpx.HTTPStatusError. - Sync stubs share an
httpx.Client, async stubs anhttpx.AsyncClient; both close on container shutdown.
Base URL from config instead of code:
http:
timeout_seconds: 10
clients:
users:
base_url: https://users.internal
@http_client(name="users")
class UsersApi: ...
Compose with the rest of the ecosystem: stack @retryable / @circuit_breaker (pico-resilience) on the same methods, and pico-otel traces the underlying httpx calls.
Documentation
Full documentation: https://dperezcabrera.github.io/pico-httpx/
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pico_httpx-0.1.0.tar.gz.
File metadata
- Download URL: pico_httpx-0.1.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd1aa42b784422307e0d18728b16e40bf7e27d6e9799a918ecd6a01c6f850675
|
|
| MD5 |
0900a8d0e4f902b1609108f3d202bd2d
|
|
| BLAKE2b-256 |
74dfe98f4c8c4c25284cc151bfdf57c6fb468ab3457af4de39af8777f37abb22
|
Provenance
The following attestation bundles were made for pico_httpx-0.1.0.tar.gz:
Publisher:
publish-to-pypi.yml on dperezcabrera/pico-httpx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pico_httpx-0.1.0.tar.gz -
Subject digest:
fd1aa42b784422307e0d18728b16e40bf7e27d6e9799a918ecd6a01c6f850675 - Sigstore transparency entry: 2137502516
- Sigstore integration time:
-
Permalink:
dperezcabrera/pico-httpx@ef0b2a5f9413e27eee90d4081a880a9dff26241b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dperezcabrera
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ef0b2a5f9413e27eee90d4081a880a9dff26241b -
Trigger Event:
release
-
Statement type:
File details
Details for the file pico_httpx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pico_httpx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21d35455413b02be436e6edcb7bc386fa76350c51e33b57a4b02407a4b0665f3
|
|
| MD5 |
62c01f4250ff4076b0a5008adb7b4fa0
|
|
| BLAKE2b-256 |
2eb95205dc6c17b6076576047203a061ff03b7b0a431fc7f17809bda5cbcfbce
|
Provenance
The following attestation bundles were made for pico_httpx-0.1.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on dperezcabrera/pico-httpx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pico_httpx-0.1.0-py3-none-any.whl -
Subject digest:
21d35455413b02be436e6edcb7bc386fa76350c51e33b57a4b02407a4b0665f3 - Sigstore transparency entry: 2137502740
- Sigstore integration time:
-
Permalink:
dperezcabrera/pico-httpx@ef0b2a5f9413e27eee90d4081a880a9dff26241b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dperezcabrera
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@ef0b2a5f9413e27eee90d4081a880a9dff26241b -
Trigger Event:
release
-
Statement type: