Skip to main content

Generate loveable Python HTTP API Clients

Project description

⚜️ 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.

It's easy to use:

# Install as a global tool - it's not a dependency!
pipx install clientele
# Generate a client
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.

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
        ...

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.4.
  • 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 black.

Project details


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.9.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

clientele-0.9.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clientele-0.9.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.6.0

File hashes

Hashes for clientele-0.9.0.tar.gz
Algorithm Hash digest
SHA256 5a15522856808b910e07dfbbacf1b7e07fd44b0db34967d6a6e3d3b1235a3456
MD5 c2e3293d75adcdfaefdc4793d99d618e
BLAKE2b-256 a08e4ef47c7ed327df183d2d79ae7de66f547c63470c6f4a2d2f69fbb3db2d12

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clientele-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.6.0

File hashes

Hashes for clientele-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26254cb19e01e499865b60b88975f8268e3064e780bf6a094ec4ef1c3a01b7e6
MD5 b9f4961f724eb9a0851d3fb7351b2d08
BLAKE2b-256 48e5ba0d3e12685acc05916f28ffdcf4c3daee3daa80d925440eee62a88f5659

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page