Loveable API Clients from OpenAPI schemas
Project description
⚜️ Clientele
Loveable API Clients from OpenAPI schemasClientele lets you generate fully-typed, loveable Python API Clients from OpenAPI schemas:
from my_api import client, schemas
# Pydantic-typed inputs
data = schemas.RequestDataRequest(my_input="test")
# Easy to read client functions
response = client.request_data_request_data_post(data=data)
# Handle responses elegantly
match response:
case schemas.RequestDataResponse():
# Handle valid response
...
case schemas.ValidationError():
# Handle validation error
...
The generated code is tiny - the example schema we use for documentation and testing only requires 250 lines of code and 5 files.
Choose either sync or async - we support both, and you can switch between them easily:
from my_async_api import client
# Async client functions
response = await client.simple_request_simple_request_get()
All generated from a single command:
# add -asyncio -t to make it async
clientele generate -u https://raw.githubusercontent.com/phalt/clientele/main/example_openapi_specs/best.json -o api_client/
(That works - try it now!)
Other features
- Supports authentication automatically (curently only HTTP Bearer and HTTP Basic auth).
- Written entirely in Python - no need to install any other languages.
- The client footprint only requires
httpx
andpydantic
. - Support your own configuration - we provide an entry point that will never be overwritten.
- Designed for easy testing with respx.
We're built on:
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
clientele-0.5.2.tar.gz
(13.4 kB
view hashes)
Built Distribution
clientele-0.5.2-py3-none-any.whl
(18.3 kB
view hashes)
Close
Hashes for clientele-0.5.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba02236d8a0115ab97df19ff2eccc0be529298a4ecadbf7ffe8354fe67a8a04f |
|
MD5 | c2ac0cd29a6a395fa465a2c9147edc91 |
|
BLAKE2b-256 | d9aa119053cbfa41a1f3d1eaa163cfd1ded2dae2b23cfa726d264daa7437c79c |