Add Avro encoding support to your FastAPI application with a one-line setup
- app = FastAPI()
+ app = AvroFastAPI()
Installation
pip install avrofastapi
Usage
SERVER
from avrofastapi import AvroFastAPI
from datetime import datetime, timezone
from pydantic import BaseModel
app = AvroFastAPI()
class TestResponseModel(BaseModel) :
A: str
B: int
C: datetime
@app.get('/', response_model=TestResponseModel)
def v1Example() :
return TestResponseModel(
A='ayy',
B=1337,
C=datetime.now(timezone.utc),
)
if __name__ == '__main__' :
from uvicorn.main import run
run(app, host='0.0.0.0', port=5000)
CLIENT
from avrofastapi.gateway import Gateway
from datetime import datetime
from pydantic import BaseModel
import requests
import asyncio
class TestResponseModel(BaseModel) :
A: str
B: int
C: datetime
requests.get('http://localhost:5000/').json()
# returns: {'A': 'ayy', 'B': 1337, 'C': '2023-01-22T10:01:00.543317+00:00'}
gateway = Gateway('http://localhost:5000/', 'v1Example__get', response_model=TestResponseModel)
asyncio.run(gateway())
# returns: TestResponseModel(A='ayy', B=1337, C=datetime.datetime(2023, 1, 22, 10, 2, 29, 641314, tzinfo=<avro.timezones.UTCTzinfo object at 0x7efbe9cdb580>))
Development
Fork the parent repository at https://github.com/kheina-com/avrofastapi and edit like any other python project.
Tests are run with pytest in the command line and input sorting is run via isort .
License
This work is licensed under the Mozilla Public License 2.0, allowing for public, private, and commercial use so long as access to this library's source code is provided. If this library's source code is modified, then the modified source code must be licensed under the same license or an applicable GNU license and made publicly available.
Metadata
Release files for avrofastapi 0.0.6
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 | |
|---|---|---|---|---|
| avrofastapi-0.0.6.tar.gz | 26.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| avrofastapi-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.2 kB
Release files / avrofastapi-0.0.6.tar.gz
| Download URL | avrofastapi-0.0.6.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3c9ec59c179cb9f0e1a3856b4317ef4b9aa29570c0a4e5e5fd25bf9e5cd8c32
|
|
BLAKE2b-256 checksum How to use checksums |
b225ebf1d8120dad50d1fe859d582a3e5b6ee69a33b41a583d40a4570ec5040b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / avrofastapi-0.0.6-py3-none-any.whl
| Download URL | avrofastapi-0.0.6-py3-none-any.whl |
|---|---|
| Size | 28.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3d92baa0801479bec93d555e9ef267b1c60dfd873a8ab8b866c04ce4ae7ad73
|
|
BLAKE2b-256 checksum How to use checksums |
67a18001fff2e7373dce80e93729337155ed9686804c022b09e0c66208890cf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for avrofastapi 0.0.6
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.