I write a lot of back end code and sometimes have to make use of HTTP endpoints. Sometimes I want to test those endpoints. I used to use httpbin.org for my endpoint testing, but over time noticed that some of the endpoints were returning HTTP 5xx errors. Some investigation reveals that the project seems to be abandoned, with open issues going all the way back to 2017. That’s not so good.
So I decided to build my own.
In this post I’d like to talk about FastAPI Httpbin. But before I can, I need to talk about FastAPI itself. FastAPI is a framework for building high-performance frameworks in Python based on Python type hints. The really neat thing about FastAPI is that your function definition for each endpoint is the source of truth–FastAPI handles argument validation for any calls to that endpoint, and generates the appropriate Swagger documentation for that endpoint.
I then went about building my own version of Httpbin, which I call FastAPI Httpbin. The source can be found here.
- https://httpbin.dmuth.org/get – Return GET method data
- https://httpbin.dmuth.org/post – Return POST method data
- https://httpbin.dmuth.org/headers – Return headers that were sent by the browser
- https://httpbin.dmuth.org/redirect/3?code=301 – Redirect 3 times with HTTP 301
- https://httpbin.dmuth.org/uuid – Return a type 4 (random) UUID
- https://httpbin.dmuth.org/uuid/qrcode – Return a QR Code of a random UUID
- https://httpbin.dmuth.org/cookies – Get, set, or delete cookies in the web browser
That’s about all I have for now, but I am actively developing this app, and I am open to any feature requests, bug fixes, or suggestions!