fastapi-hypermodel
fastapi-hypermodel copied to clipboard
A FastAPI + Pydantic extension for simplifying hypermedia-driven API development.
FastAPI-HyperModel
Simple hypermedia for FastAPI
Documentation: https://jtc42.github.io/fastapi-hypermodel/
Source Code: https://github.com/jtc42/fastapi-hypermodel
FastAPI-HyperModel is a FastAPI + Pydantic extension for simplifying hypermedia-driven API development.
Hypermedia consist of enriching API responses by providing links to other URIs within the services to fetch related resources or perform certain actions. There are several levels according to the Hypermedia Maturity Model Levels. Using Hypermedia makes APIs reach Level 3 of the Richardson Maturity Model (RMM), which involves leveraging Hypertext As The Engine Of Application State (HATEOAS), that is, Hypermedia.
Below are some examples of responses using hypermedia. For detailed examples, check the docs.
Format | Response |
---|---|
No Hypermedia |
|
Level 0 Hypermedia (URLFor) |
|
Level 1 Hypermedia (HAL) |
|
Level 2 Hypermedia (Siren) |
|
Installation
pip install fastapi-hypermodel
Limitations
Currently, query parameters will not resolve correctly. When generating a resource URL, ensure all parameters passed are path parameters, not query parameters.
This is an upstream issue, being tracked here.
Attributions
Huge thanks to @christoe for building support for Pydantic 2.