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 |
{
"id_": "item01",
"name": "Foo",
"price": 10.2,
}
|
|
Level 0 Hypermedia (URLFor) |
{
"id_": "item01",
"name": "Foo",
"price": 10.2,
"href": "/items/item01",
"update": "/items/item01"
}
|
|
Level 1 Hypermedia (HAL) |
{
"id_": "item01",
"name": "Foo",
"price": 10.2,
"_links": {
"self": {"href": "/items/item01"},
"update": {"href": "/items/item01"},
},
}
|
|
Level 2 Hypermedia (Siren) |
{
"properties": {
"id_": "item01",
"name": "Foo",
"price": 10.2
},
"links": [
{
"rel": ["self"],
"href": "/items/item01"
}
],
"actions": [
{
"name": "update",
"method": "PUT",
"href": "/items/item01",
"type": "application/x-www-form-urlencoded",
"fields": [
{
"name": "name",
"type": "text",
"value": "Foo"
},
{
"name": "description",
"type": "text",
"value": "None"
},
{
"name": "price",
"type": "number",
"value": "10.2"
}
]
}
]
}
|
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.
Metadata
Release files for fastapi-hypermodel 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_hypermodel-2.2.0.tar.gz | 17.2 kB | Without provenance | Details for fastapi_hypermodel-2.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_hypermodel-2.2.0-py3-none-any.whl | Python 3 | none | any | Details for fastapi_hypermodel-2.2.0-py3-none-any.whl |
Total release size: 40.5 kB
Release files / fastapi_hypermodel-2.2.0.tar.gz
| Download URL | fastapi_hypermodel-2.2.0.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cd725b1573037aebde339d66f6b1e306ba3a5b0e3481203e6e243ea1b9f4bd1
|
|
BLAKE2b-256 checksum How to use checksums |
ff9b0b1a9a65681dc1b2971c8670d03c82163516eb041589b629f301842f8f33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.9.20 Linux/6.5.0-1025-azure
|
Release files / fastapi_hypermodel-2.2.0-py3-none-any.whl
| Download URL | fastapi_hypermodel-2.2.0-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3db1b0a7e0367ebb090a4f9c871e995803c942c1fc10a29894a27475a7d16b7b
|
|
BLAKE2b-256 checksum How to use checksums |
279a150f6bcc9ab778f97a202c0eb8de8a2025d80403ba19b1fb1feb7d20599b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.9.20 Linux/6.5.0-1025-azure
|
Security for fastapi-hypermodel 2.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.