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

Pydantic Badge Http Badge

Example code

from clientele import api
from pydantic import BaseModel

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

class Pokemon(BaseModel):
    name: str

@client.get("/pokemon/{id}")
def get_pokemon_name(id: int, result: Pokemon) -> str:
    return result.name

See more examples

Why use Clientele?

  • A comfortable abstraction - Encourages consistency and focus on the functionality.
  • Easy to learn - Clientele is visually similar to popular python API server frameworks.
  • Easy to test - All the testing tools you need to maintain API integrations.
  • Easy to configure - Sensible HTTP defaults and plenty of hooks for customisation.
  • Easy data validation - Built in data validation using Pydantic.
  • Core built-ins - Caching, Network, and Retry handling built specifically for HTTP.
  • Use your own HTTP - Clientele can support any Python HTTP library.
  • 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: CreateBookResponse) -> CreateBookResponse:
    return result

Streaming responses

from typing import AsyncIterator

from clientele import api
from pydantic import BaseModel


client = api.APIClient(base_url="https://httpbin.org")


class Event(BaseModel):
    id: int
    url: str


@client.get("/stream/{n}", streaming_response=True)
async def stream_events(n: int, result: AsyncIterator[Event]) -> AsyncIterator[Event]:
    return result

Works with Python API frameworks

Building an API service in Python? Clientele can build you a client library in seconds.

Clientele is 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.
  • Decorated 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

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.10.0.tar.gz (1.3 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.10.0-py3-none-any.whl (87.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for clientele-1.10.0.tar.gz
Algorithm Hash digest
SHA256 a9926b796321906e144d958abb7bc91d3f9da236703e37d1a57bfcecaef231c9
MD5 291684a53f612e6fe3e93f25d744638b
BLAKE2b-256 62726a311da2209f259bf94bbc6443d59d2f5975e94a28745dce56a1a6c179e1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for clientele-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a2f0d25f6287f5b2f33567f12237a81f72a66d964faefbccb58e58ad7749046
MD5 b9b375667a89b0f4df15258b6ecb8c20
BLAKE2b-256 312b20f1048e5f54fdd4a2aeea84e5c7289025c62ddf51cc89b636cb5a0e9849

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