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

See more examples

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

Sensible HTTP caching

from clientele import api, cache

client = api.APIClient(base_url="https://pokeapi.co/api/v2")

@cache.memoize(ttl=300)
@client.get("/pokemon/{pokemon_name}")
def get_pokemon_info(pokemon_name: str, result: dict) -> dict:
    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.5.0.tar.gz (1.9 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.5.0-py3-none-any.whl (107.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for clientele-1.5.0.tar.gz
Algorithm Hash digest
SHA256 0b340a156068e578ec346b9a6acde49e2bb776a12bc18ff19909c71e504960c5
MD5 3bbc84bf9c234a87221d6cacef7286a3
BLAKE2b-256 c8d87b6efe02485aa046c061a3e736bca89247ef69475cd7f5108869bd242294

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for clientele-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 466db0d438d833cb1e049c2c0474d8b8ce853a1ce03cc2df3a683702da6e84bc
MD5 c028e764c8f5bf4a22373af9566c34c6
BLAKE2b-256 42cdd5c48dc0eb79b556c15784d564a25dfa162326f79433d85bc2c6af7f1d25

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 Pingdom Monitoring Sentry Error logging StatusPage Status page