⚜️ Clientele
Example code
from clientele import api
from .schemas import Pokemon
client = api.APIClient(base_url="https://pokeapi.co/api/v2/")
@client.get("/pokemon/{id}")
def get_pokemon_name(id: int, result: Pokemon) -> str:
return result.name
Why use Clientele?
- Just modern Python - Types, Pydantic, and HTTPX, that's it.
- Easy to learn - Clientele is visually similar to popular python API server frameworks.
- Easy to test - Works with existing tools like respx and pytest-httpx.
- Easy to configure - Clientele has sensible defaults and plenty of hooks for customisation.
- A comfortable abstraction - Focus on the data and the functionality, not the connectivity.
- OpenAPI support - Build your own client, or scaffold one from an OpenAPI schema.
Async support
@client.get("/pokemon/{id}")
async def get_pokemon_name(id: int, result: Pokemon) -> str:
return result.name
Automatic data validation
from clientele import api as clientele_api
from .my_pydantic_models import CreateBookRequest, CreateBookResponse
client = clientele_api.APIClient(base_url="http://localhost:8000")
@client.post("/books")
def create_book(data: CreateBookRequest, result: CreateBookReponse) -> CreateBookResponse:
return result
Streaming responses
from typing import AsyncIterator
from pydantic import BaseModel
from clientele import api
client = api.APIClient(base_url="http://localhost:8000")
class Event(BaseModel):
text: str
@client.get("/events", streaming_response=True)
async def stream_events(*, result: AsyncIterator[Event]) -> AsyncIterator[Event]:
return result
Works with Python API frameworks
Built and tested to be 100% compatible with the OpenAPI schemas generated from:
- FastAPI
- Django REST Framework via drf-spectacular
- Django Ninja
See the working demos in our server_examples/ directory.
OpenAPI support
Clientele can create scaffolding for an API client from an OpenAPI schema with:
- Pydantic models generated from the schema objects.
- Smart function signatures generated from schema operations.
- Async support if you want a client with concurrency.
- A tiny output that is only 3 files big.
- Regeneration-friendly - update your API, regenerate, review the git diff, then ship it!
- Formatted code thanks to Ruff.
API Client explorer
Clientele has an explore mode for quickly testing and debugging APIs through an interactive REPL:
# Explore an existing clientele-compatible client
uvx clientele explore -c my_clientele_client/
# Or generate a temporary client from any OpenAPI service on the web
uvx clientele explore -u https://raw.githubusercontent.com/PokeAPI/pokeapi/master/openapi.yml
# 🤫 Pssst! Copy and paste this right now to try it!
- Autocomplete for operations and schemas.
- Execute API operations to test the API.
- Inspect schemas to see what the objects look like.
- Modify configuration within the REPL as you're testing.
Getting Started
👉 Read the full documentation for all documentation.
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 clientele-1.6.0.tar.gz.
File metadata
- Download URL: clientele-1.6.0.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40fbd0c6b91b6aeb6f48438838c30da1a4ec5377b9d6599443381e4939a49d33
|
|
| MD5 |
30bdf52da1e99a5bcd5245539afb17ef
|
|
| BLAKE2b-256 |
4cb33f38ac4fad46ef45765ef03d2ae2e2daccb0168695bc8c153d451168b571
|
File details
Details for the file clientele-1.6.0-py3-none-any.whl.
File metadata
- Download URL: clientele-1.6.0-py3-none-any.whl
- Upload date:
- Size: 113.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43e24d116429d38e1fa30cdda239795e29b4e3e81ab763bc1ce5c9a010227626
|
|
| MD5 |
70ea62f0a03d7cadcc0279afa2047cbf
|
|
| BLAKE2b-256 |
25ef24ecd9e328015576591bab537e01aca0d58a32b78b989945946d9409aadf
|