Metadata-Version: 2.1
Name: clientele
Version: 0.5.1
Summary: Loveable API Clients from OpenAPI schemas
Home-page: https://phalt.github.io/clientele/
License: MIT
Author: Paul Hallett
Author-email: paulandrewhallett@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: click (>=8.1.3,<9.0.0)
Requires-Dist: httpx (>=0.24.1,<0.25.0)
Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
Requires-Dist: openapi-core (==0.18.0)
Requires-Dist: pydantic (>=2.1.1,<3.0.0)
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
Requires-Dist: rich (>=13.4.2,<14.0.0)
Requires-Dist: types-pyyaml (>=6.0.12.11,<7.0.0.0)
Description-Content-Type: text/markdown

<p align="center">
    <h1>⚜️ Clientele</h1>
    <em>Loveable API Clients from OpenAPI schemas</em>
    <img src="https://github.com/phalt/clientele/blob/main/docs/clientele.jpeg?raw=true">
</p>

<p align="center">
<a href="https://pypi.org/project/clientele" target="_blank">
    <img src="https://img.shields.io/pypi/v/clientele?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://pypi.org/project/clientele" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/clientele.svg?color=%2334D058" alt="Supported Python versions">
</a>
</p>

Clientele lets you generate fully-typed, loveable Python API Clients from OpenAPI schemas:

```py
from my_api import client, schemas

# Pydantic-typed inputs
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](https://github.com/phalt/clientele/blob/0.4.4/example_openapi_specs/best.json) we use for documentation and testing only requires [250 lines of code](https://github.com/phalt/clientele/tree/0.4.4/tests/test_client) and 5 files.

Choose either sync or async - we support both, and you can switch between them easily:

```py
from my_async_api import client

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

All generated from a single command:

```sh
# add -asyncio -t to make it async
clientele generate -u https://raw.githubusercontent.com/phalt/clientele/main/example_openapi_specs/best.json -o api_client/
```

(That works - try it now!)

## Other features

* Supports authentication automatically (curently only HTTP Bearer and HTTP Basic auth).
* Written entirely in Python - no need to install any other languages.
* The client footprint only requires `httpx` and `pydantic`.
* Support your own configuration - we provide an entry point that will never be overwritten.
* Designed for easy testing with [respx](https://lundberg.github.io/respx/).

We're built on:

* [Pydantic 2.0](https://docs.pydantic.dev/latest/)
* [httpx](https://www.python-httpx.org/)
* [openapi-core](https://openapi-core.readthedocs.io/en/latest/)

