Skip to main content

Clientele is a different way to build Python API Clients

Project description

⚜️ Clientele

What is Clientele?

Clientele is a comprehensive framework for building and maintaining API Integrations.

Focus on the functionality and the data you want from an API, and let Clientele handle the rest.

Build, test, and maintain API integrations confidently.

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.
  • GraphQL support - Clientele has a GraphQLClient tailored for GraphQL APIs.

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

GraphQL support

from pydantic import BaseModel
from clientele.graphql import GraphQLClient

client = GraphQLClient(base_url="https://api.github.com/graphql")

class Repository(BaseModel):
    name: str
    stargazerCount: int

class RepositoryQueryData(BaseModel):
    repository: Repository

class RepositoryQueryResponse(BaseModel):
    data: RepositoryQueryData

@client.query("""
    query($owner: String!, $name: String!) {
        repository(owner: $owner, name: $name) {
            name
            stargazerCount
        }
    }
""")
def get_repo(owner: str, name: str, result: RepositoryQueryResponse) -> Repository:
    return result.data.repository

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.

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-2.2.1.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-2.2.1-py3-none-any.whl (79.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clientele-2.2.1.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clientele-2.2.1.tar.gz
Algorithm Hash digest
SHA256 3ab6be9c08019f0c6cf6d4ed94b4d14d24455ce1c9e4daf2a47be479b935fdfc
MD5 0256cdb7449b5886e9f5c8b7ab4b57b9
BLAKE2b-256 bf91d742ddfe6404a72528411d17a0322e71a19c93332ad1a972aed4f00eaa95

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clientele-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 79.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clientele-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f979c2326809a1849f92ee734778fd22a0021093b0f4cb3b3213c7e47a67206
MD5 e05a347a2bdd78ed389b8126e0fa275c
BLAKE2b-256 94e8084c876fcade807649e0e8219a0e8e3dcbedb2b3fcba7ac4a932eb097339

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 Pingdom Monitoring Sentry Error logging StatusPage Status page