Skip to main content

⚜️ Clientele

Generate loveable Python HTTP API Clients

Package version PyPI - Python Version PyPI - Downloads PyPI - License

Clientele lets you generate fully-typed, pythonic HTTP API Clients using an OpenAPI schema.

Installation

Install clientele as a global CLI tool:

With Homebrew (macOS/Linux)

brew tap phalt/clientele
brew install clientele

With pipx (Python)

pipx install clientele

With uv (Python)

uv tool install clientele

Quick Start

# Generate a client from an OpenAPI schema
clientele generate -u https://raw.githubusercontent.com/phalt/clientele/main/example_openapi_specs/best.json -o api_client/

Generated code

The generated code is designed by python developers, for python developers.

It uses modern tooling and has a great developer experience.

Function-based client

from my_api import client, schemas

# Pydantic models for inputs and outputs
data = schemas.RequestDataRequest(my_input="test")

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

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

Class-based client

Prefer object-oriented programming? Use clientele generate-class to generate a client with a Client class:

from my_api.client import Client
from my_api import schemas

# Instantiate the client
client = Client()

# Pydantic models for inputs and outputs
data = schemas.RequestDataRequest(my_input="test")

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

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

The generated code is tiny - the example schema we use for documentation and testing only requires 250 lines of code and 5 files.

Async support

You can choose to generate either a sync or an async client - we support both:

from my_async_api import client

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

Other features

  • Written entirely in Python.
  • Designed to work with FastAPI's and drf-spectacular's OpenAPI schema generator.
  • The generated client only depends on httpx and Pydantic 2.9+.
  • HTTP Basic and HTTP Bearer authentication support.
  • Support your own configuration - we provide an entry point that will never be overwritten.
  • Designed for easy testing with respx.
  • API updated? Just run the same command again and check the git diff.
  • Automatically formats the generated client with Ruff.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clientele-0.10.0.tar.gz (4.7 MB view details)

Uploaded Source

Built Distribution

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

clientele-0.10.0-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for clientele-0.10.0.tar.gz
Algorithm Hash digest
SHA256 18711e6a619cfddbdcce591b4d666297e619c7d86b1ed34ca0dc4416dceb9d2d
MD5 a27760ca9123e59ac56180a9f7d3360a
BLAKE2b-256 bb71a49308a01c456eb935d6d2e16e9a4ecc9607624e777770f2ceb0a6524e0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for clientele-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f47899e5c575ccbed54fb8f7ddf794c2e8ed36865b2585168c5a088f2f893511
MD5 f9e8086f6b02197f11d459155518183b
BLAKE2b-256 dede397b73cadd6468f7122eb92262f08fd40a1e79e68b5db01417d9d805c9fc

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