APIModel
Advanced models for non-standard modern JSON APIs.
Documentation: https://apimodel.readthedocs.io/en/latest/
Source Code: https://github.com/thesadru/apimodel
Advanced models for non-standard modern JSON APIs. Supports extensive conversion and validation with several tools to help speed up development. Works with both synchronous and asynchronous models seamlessly. Fully tested and type-hinted.
Key Features
- Seamless data parsing through annotations.
- Supports extensive conversion and validation.
- Automatic code generation from json to speed up development.
- Inspired by pydantic to ensure familiarity.
- Localization support.
- Fully tested and type-hinted.
- No requirements.
Example
You can see more examples in the docs.
import typing
import datetime
import apimodel
class User(apimodel.APIModel):
id: int
username: str
profile: str
# UNIX or ISO parsing
created_at: datetime.datetime
@apimodel.validator()
def _complete_profile_url(self, profile: str) -> str:
"""Take the raw profile ID and turn it into a full url"""
return f"https://example.com/assets/profile/{profile}.png"
# inheritance
class Attendee(User):
status: typing.Literal["attending", "interested", "absent"] | None = None
@apimodel.root_validator()
def _parse_status(self, values: dict[str, typing.Any]) -> dict[str, typing.Any]:
"""Take the entire JSON and update it accordingly"""
# made for non-standard APIs
if "attending" in values:
values["status"] = "attending" if values["attending"] else "absent"
elif "interested" in values:
values["status"] = "interested" if values["interested"] else "absent"
# excess values get thrown away
return values
class Event(apimodel.APIModel):
# allow easily renaming fields
time: datetime.datetime = apimodel.Field(alias="happening_at")
# clean nested models
attendees: list[User]
Metadata
Release files for apimodels 0.0.1
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 |
|---|---|---|---|---|
| apimodels-0.0.1.tar.gz | 21.9 kB | Without provenance | Details for apimodels-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apimodels-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for apimodels-0.0.1-py3-none-any.whl |
Total release size: 46.4 kB
Release files / apimodels-0.0.1.tar.gz
| Download URL | apimodels-0.0.1.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2731bacc5ac2c8de6d8cf76fb03628856371295ceb7fcdec6fa8b0e7644461ec
|
|
BLAKE2b-256 checksum How to use checksums |
b15aa41a5851a0047422eb48b84fc6d3068880bf10fcf51437cae366395ebf97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.6
|
Release files / apimodels-0.0.1-py3-none-any.whl
| Download URL | apimodels-0.0.1-py3-none-any.whl |
|---|---|
| Size | 24.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce01ebfb66eacb1e0017b146838e8c49837334c359e3c23d8e84c00d2b684524
|
|
BLAKE2b-256 checksum How to use checksums |
9b0089f89ba81fb1448a6f3d8bb0efe85458b7a19ef34a9b410aa2b3344f3f2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.6
|
Security for apimodels 0.0.1
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.