Skip to main content

⚜️ Clientele

Package version Python versions codecov PyPI Downloads PyPI - License OpenAPI Compatibility

Clientele generates fully-typed, idiomatic python HTTP API clients from OpenAPI 3.0+ schemas.

It is designed and tested to work perfectly with the most popular Python API frameworks:

What Clientele Does

Clientele transforms your OpenAPI schema into a clean, maintainable Python HTTP client with:

  • Developer first approach designed for a loveable developer experience.
  • Pydantic models for request and response validation.
  • Fully-typed function signatures for IDE autocomplete and type checking.
  • Async support if you want a concurrent client.
  • Multiple formats - class-based or functional, you can choose.
  • Tiny output - the generated code is readable, debuggable Python with only two dependencies.
  • Regeneration-friendly - update your API, regenerate, review the git diff, then ship it!
  • API REPL - a dedicated REPL for exploring and testing the client.
  • Deterministic: No expensive LLMs, no hallucinations - same input always produces same output.

When to Use Clientele

Consumer

  • You want to use an HTTP API that has an OpenAPI schema
  • And you want to consume that API from a Python application
  • And you want type safety and validation without manual schema maintenance
  • And you want code that is readable, maintainable, and extendable to suit your project

Publisher

  • You have an HTTP API that has an OpenAPI schema
  • And you want to offer a client library in Python
  • And you want developers to love using the client

Installation

Clientele can be installed in several ways:

Using UV (Recommended)

uv tool install clientele

Using Homebrew (macOS/Linux)

brew install phalt/clientele/clientele

Using pip

pip install clientele

Quick Start

# Generate a client from the PokeAPI OpenAPI schema
clientele generate -u https://raw.githubusercontent.com/PokeAPI/pokeapi/master/openapi.yml -o pokeapi_client/
# Load the REPL to start testing with the generated code immediately
clientele explore -c pokeapi_client/

generate_gif

The generated code

We offer many different flavours of client to suit your needs:

Function-based client

from my_api import client, schemas

# Pydantic models for inputs and outputs
data = schemas.CreateBookRequest(title="My awesome book")

# Easy to read client functions
response = client.create_book(data=data)

# Handle responses elegantly
match response:
    case schemas.CreateBookResponse():
        # Handle valid response
        ...
    case schemas.ValidationError():
        # Handle validation error
        ...

Class-based client

from my_api.client import Client
from my_api import schemas

# Instantiate the client
client = Client()

# Pydantic models for inputs and outputs
data = schemas.CreateBookRequest(title="My awesome book")

# Call API methods on the client instance
response = client.create_book(data=data)

# Handle responses elegantly
match response:
    case schemas.CreateBookResponse():
        # Handle valid response
        ...
    case schemas.ValidationError():
        # Handle validation error
        ...

Async support

For both class-based and functional clients we can produce async versions:

from my_async_api import client

# Async client functions
response = await client.list_books()

API Explorer

repl demo

Clientele includes an interactive REPL that lets you explore and test APIs without writing any code:

# Explore an existing client
clientele explore -c pokeapi_client/

# Or generate a temporary client from any OpenAPI service on the web and start using it immediately
clientele explore -u https://raw.githubusercontent.com/PokeAPI/pokeapi/master/openapi.yml

═══════════════════════════════════════════════════════════
  Clientele Interactive API Explorer v1.0.1
═══════════════════════════════════════════════════════════

Type /help or ? for commands, /exit or Ctrl+D to quit
Type /list to see available operations

Press TAB for autocomplete

>>>

Explorer Features

  • Autocomplete: Press TAB to discover operations and parameters with type hints.
  • Execute instantly: Execute API operations with Python-like syntax.
  • Beautiful output: Syntax-highlighted JSON responses.
  • Command history: Navigate previous commands with UP/DOWN arrows.
  • Local config: Modify configuration locally as you're testing.
  • Debug mode: Run debug mode to see diagnostics and errors.

OpenAPI Compatibility

Clientele works by traversing OpenAPI 3.0+ schemas.

Any framework or tool that generates standards-compliant OpenAPI schemas should work with Clientele.

Verified Compatibility

We test Clientele against 2000+ real-world OpenAPI schemas from the APIs.guru OpenAPI Directory through a CI cron job.

As of our latest run, we successfully generate clients for 95.39% of schemas in the directory.

OpenAPI Compatibility

Additionally we have specifically built and tested Clientele to support:

  • FastAPI - 100% compatibility with FastAPI's built-in OpenAPI schema generation.
  • Django REST Framework with drf-spectacular - Full support for DRF's OpenAPI schemas.
  • Django Ninja - Works with Django Ninja's OpenAPI output.

Server Examples

Working example server applications are available in the server_examples/ directory. Read more about each in our documentation:

These examples match the code shown in our framework-specific documentation and provide real, working servers you can run locally to test Clientele's client generation.

Additional Features

  • Authentication: HTTP Basic and HTTP Bearer authentication built-in.
  • Configuration: A config.py entry point that's never overwritten on regeneration.
  • Testing: Designed for easy testing thanks to respx.
  • Formatting: Automatically formats generated code with Ruff.

Getting Started

👉 See our framework-specific guides for FastAPI, Django REST Framework, and Django Ninja

👉 Read the full documentation for advanced usage

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.0.1.tar.gz (3.1 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.0.1-py3-none-any.whl (76.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for clientele-1.0.1.tar.gz
Algorithm Hash digest
SHA256 80a438a9ed105d1263e96f4d0bceccf026d63752d7882a6549acfc6370912750
MD5 d2285b3ab98bb26f91194787cf3ec2ba
BLAKE2b-256 e2986b2db2f3fb52821f93f628458c55df6af7037354dee11cc6ad43ae152e3e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for clientele-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6db3ba949953419ea116d4d434ba539d122ff71c5eec8f98cc4d02d6112d4aa9
MD5 3115543f7bcbbefaae0d88e368d2f637
BLAKE2b-256 6b083bf265272c1028237c8918f8db8e6a8b3ff6f5b184ff31daa76b0bf182ab

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