Generate loveable Python HTTP API Clients
Project description
⚜️ Clientele
Generate loveable Python HTTP API Clients
Clientele lets you generate fully-typed, pythonic HTTP API Clients using an OpenAPI schema.
It's easy to use:
# Install as a global tool - it's not a dependency!
pipx install clientele
# Generate a client
clientele generate -u https://raw.githubusercontent.com/phalt/clientele/main/example_openapi_specs/best.json -o api_client/
Generated code
The generated code is designed by python developers, for python developers.
It uses modern tooling and has a great developer experience.
from my_api import client, schemas
# Pydantic models for inputs and outputs
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.
Async support
You can choose to generate either a sync or an async client - we support both:
from my_async_api import client
# Async client functions
response = await client.simple_request_simple_request_get()
Other features
- Written entirely in Python.
- The generated client only depends on httpx and Pydantic 2.4.
- HTTP Basic and HTTP Bearer authentication support.
- Support your own configuration - we provide an entry point that will never be overwritten.
- Designed for easy testing with respx.
- API updated? Just run the same command again and check the git diff.
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.6.3.tar.gz
(13.9 kB
view details)
Built Distribution
clientele-0.6.3-py3-none-any.whl
(19.4 kB
view details)
File details
Details for the file clientele-0.6.3.tar.gz
.
File metadata
- Download URL: clientele-0.6.3.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-84-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cee02c492a5b6ad4e8eaacbfd20a169e314fe20f874a95bfea66df2591d355ba |
|
MD5 | 732b5b0b356349ccbf80aa065d296f06 |
|
BLAKE2b-256 | 611a0eeadefaa964ae8efd0c64080a0dcb23e5630357aed49b2868f1636d94c5 |
File details
Details for the file clientele-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: clientele-0.6.3-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-84-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0340a1053e6424ab6478e111b90ec3b5e05541d5ee9edaab83a920ca94e19849 |
|
MD5 | 4583714deb4ffbab818c12dd6d96f32e |
|
BLAKE2b-256 | 738ed19336e0e58685a1c0f477024c962a72dd180c5675129a7fa38b2c36c78f |