Skip to main content

⚜️ Clientele

      ___ _ _            _       _
     / __\ (_) ___ _ __ | |_ ___| | ___
    / /  | | |/ _ \ '_ \| __/ _ \ |/ _ \
   / /___| | |  __/ | | | ||  __/ |  __/
   \____/|_|_|\___|_| |_|\__\___|_|\___|

⚜️ Clientele is a different way to think about Python API Clients

Package version Python versions PyPI - License codecov PyPI Downloads

Works with OpenAPI Compatibility

Why use Clientele?

  • Inspired by FastAPI - write API clients as easily as you would write API servers.
  • A neat abstraction - Focus on the data, let Clientele manage everything else.
  • Modern python - Python Types, Pydantic, and httpx, that's it.
  • Easy to learn - No complexity, beautiful developer experience, easy to read.
  • Easy to configure - sane defaults, but plenty of hooks for customisation and control.

A Simple Example

from clientele import api as clientele_api
from .my_pydantic_models import Book

client = clientele_api.APIClient(base_url="http://localhost:8000")

@client.get("/book/{book_id}")
def get_book(book_id: int, result: Book) -> Book:
    return result

# Or just return the data you want!
@client.get("/book/{book_id}")
def get_book_title(book_id: int, result: Book) -> str:
    return result.title

Async support

from clientele import api as clientele_api
from .my_pydantic_models import Book

client = clientele_api.APIClient(base_url="http://localhost:8000")


# Note: mix sync and async in one client if you want!
@client.get("/book/{book_id}")
async def get_book(book_id: int, result: Book) -> Book:
    return result

Input and output validation with Pydantic

from clientele import api as clientele_api
from .my_pydantic_models import CreateBookRequest, CreateBookResponse

client = clientele_api.APIClient(base_url="http://localhost:8000")


# Strongly typed inputs and outputs
@client.post("/books")
def create_book(data: CreateBookRequest, result: CreateBookReponse) -> CreateBookResponse:
    return result

API Client generator

Clientele can create scaffolding for an API client from an OpenAPI schema with:

  • A 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 client with concurrency.
  • A tiny output - clientele is readable, debuggable Python.
  • Regeneration-friendly - update your API, regenerate, review the git diff, then ship it!
  • Configuration: that's never overwritten on regeneration.
  • Testing is easy peasy with respx.
  • Formatted output with 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

Explorer Features

  • Autocomplete for operations and schemas.
  • Execute API operations with Python-like syntax.
  • Syntax-highlighted JSON responses.
  • Navigate previous commands like a python shell.
  • Modify configuration within the REPL as you're testing.
  • Run debug mode to see diagnostics and errors.

Works with your favourite Python API Servers

We have specifically built and tested Clientele to be 100% compatible with OpenAPI schemas generated from:

  • FastAPI
  • Django REST Framework via drf-spectacular
  • Django Ninja

We have working example servers in the server_examples/ directory.

These examples match the code shown in our documentation and provide real, working servers you can run locally to test out Clientele.

OpenAPI Compatibility

Clientele is compatible with OpenAPI 3.0+ schemas.

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

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.1.tar.gz (2.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-1.4.1-py3-none-any.whl (101.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for clientele-1.4.1.tar.gz
Algorithm Hash digest
SHA256 52b3191182d8ad553074734675048d8df93bc6341c33d800325ef504f12f6769
MD5 0866dd67267a65551abc557fe7232c35
BLAKE2b-256 fb742ae526bb35d52aae893a54984b1da79211280056ea77a1a2541eb0d80165

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for clientele-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e68b348f03863e418460227498445542dd4a65b572023beaeae613314cf3228
MD5 f0ce885df1974d9b933265a3b0dbf667
BLAKE2b-256 191d133b2c79dca14b66f9191c4e0935bef4c6b8fd003314ec2f17f9696d8246

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