Declarative HTTP client for Python
Project description
DeclarativeX
Description
DeclarativeX aims to make HTTP requests more declarative in Python. It uses Pydantic for data validation and Httpx for making the requests.
Installation
pip install declarativex
Usage
Here's a simple example:
from declarativex import BaseClient, get, Path
class MyClient(BaseClient):
@get("/some/path{id}")
def get_something(self, id: int = Path(...)) -> dict:
pass
client = MyClient(base_url="https://example.com/")
client.get_something(id=42)
Async with pydantic example:
import asyncio
from declarativex import BaseClient, post, Json
from pydantic import BaseModel
class MyPydanticModel(BaseModel):
name: str
age: int
class AsyncPydanticClient(BaseClient):
@post("/some/path")
async def post_something(self, data: MyPydanticModel = Json(...)) -> MyPydanticModel:
pass
client = AsyncPydanticClient(base_url="https://example.com/")
asyncio.run(client.post_something(MyPydanticModel(name="John", age=42))
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
declarativex-1.1.0.tar.gz
(16.0 kB
view hashes)
Built Distribution
Close
Hashes for declarativex-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0865d5400f93babc5e4a64d4376cf9da2ff3375882b596a2bc2bcbf041f8f25a |
|
MD5 | fc3c712c9e8061072266ee277985c264 |
|
BLAKE2b-256 | 49888242971d705bf2009fee59fc7cecb5e41e68c3cb219f476f59b7292b8934 |