Skip to main content

⚜️ Clientele

https://raw.githubusercontent.com/phalt/clientele/refs/heads/main/docs/clientele_header.png

Package version Python versions PyPI - License codecov PyPI Downloads

Works with OpenAPI Compatibility

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

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.

generate_gif

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!

repl demo

  • 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

clientele-1.4.3.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clientele-1.4.3-py3-none-any.whl (100.9 kB view details)

Uploaded Python 3

File details

Details for the file clientele-1.4.3.tar.gz.

File metadata

  • Download URL: clientele-1.4.3.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for clientele-1.4.3.tar.gz
Algorithm Hash digest
SHA256 28ffbf54eda1dc97147a94282ec7d69fb89e18eda0a3650ee7d636c4dae4eb54
MD5 80efcc3fd1c7c07f6caf9efd72492476
BLAKE2b-256 0ef53320214ebab30acab633711731e0ae79596fe413b52004724ab828d9eae5

See more details on using hashes here.

File details

Details for the file clientele-1.4.3-py3-none-any.whl.

File metadata

  • Download URL: clientele-1.4.3-py3-none-any.whl
  • Upload date:
  • Size: 100.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for clientele-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c6ab86ed7a13841f9a62c27002dad8cf47c0d912954b4877f9ba883f535541f2
MD5 bab9b787ee23e556350c513672e1fa2e
BLAKE2b-256 922f52c0ad544f88559b93c300df4bdefb5e54139b80a5a6e95a975e80b02439

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page