Clientele: The Python API Client Generator for FastAPI, Django REST Framework, and Django Ninja

Hello Djangonauts.

I’ve spent most of this past year planning and building my ultimate HTTP API client library for OpenAPI.

I’ve got it to version 1.0.0 this Christmas break and I’d love for you to try it out.

It’s the result of years of personal experience dealing with HTTP API integrations in Python.

I have tried to integrate with OpenAPI services for years, professionally or as a hobby, I’ve even built some of the most popular free APIs on the web.

But I could never find a client generator that had a good developer experience that I enjoyed.

The last time I had to hand build a client integration from scratch I decided to use it as a template and worked backwards, creating a generator that made my dream client integration.

clientele_generate

Clientele creates a fully typed, functional or class-based, async or sync HTTP API client. It has an entry point for configuration. It supports authentication. It is auto formatted by ruff. It only depends on httpx and pydantic.

You can keep using Clientele to maintain it as the API updates, or just use it once to get you started quickly with a decent HTTP client (a bit like Django’s startapp).

I tested it against 2,000+ OpenAPI schemas to make sure it works properly (through a cron job, not by hand - hah!). After that I decided to target FastAPI, DRF and Django-ninja specifically to guarantee 100% support for the Python ecosystem.

To boost the developer experience and testing I even built a REPL for quick client generation and testing or schema inspection. You can test out any OpenAPI service in less than a second, all you need is the schema file or URL.

Here is a gif of the REPL in action against a local FastAPI API:

clientele

This project is the first time in years I’ve felt invigorated and passionate about coding again so I’m happy for the journey it’s given me so far. As an aside: if you have ever felt “It’s worthless building something like that because it’s already been done” my advice is to go and do it anyway because it is very fulfilling.

You can read more about the design philosophy of the project here: Design Philosophy - ⚜️ Clientele

Please download it and give it a try!

7 Likes

Looks cool @phalt — thanks for sharing.

1 Like

Thanks for sharing. So basically you can use it for any openapi, not just DRF, FastAPI, django-ninja.