fastapi-query-conditions
Introduction
FastAPI-Query-Conditions is a dependency that parses a query string into conditions using operators enclosed in square brackets.
For example, if you send a request to /orders?amount[gte]=1000&amount[lt]=2000, you can use the query string as parsed conditions like this:
{"gte":1000,"lt":2000}
Install
> pip install fastapi-query-conditions
Quick Start
from typing import Dict
from fastapi import Depends, FastAPI
from fastapi_query_conditions import query_conditions
app = FastAPI()
@app.get("/items")
def query_items(amount: Dict[str, int] = Depends(query_conditions(field='amount', factory=int))):
print(amount)
return amount
Then, if you send a request to /items?amount[gte]=1000&amount[lt]=2000, you can check the following results.
{'gte': 1000, 'lt': 2000}
Also, you can use various factory functions for your query parameter.
from datetime import datetime
from typing import Dict
from fastapi import Depends, FastAPI
from fastapi_query_conditions import query_conditions
app = FastAPI()
@app.get("/orders")
def query_orders(time: Dict[str, int] = Depends(query_conditions(field='time', factory=datetime.fromisoformat))):
print(time)
return time
Then, if you send a request to /orders?time[gte]=2022-10-18T12:00&time[lt]=2022-10-18T12:30, you can check the following results.
{'gte': datetime.datetime(2022, 10, 18, 12, 0), 'lt': datetime.datetime(2022, 10, 18, 12, 30)}
Metadata
Release files for fastapi-query-conditions 1.0.2
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 | |
|---|---|---|---|---|
| fastapi-query-conditions-1.0.2.tar.gz | 3.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_query_conditions-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / fastapi-query-conditions-1.0.2.tar.gz
| Download URL | fastapi-query-conditions-1.0.2.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d27989d60b846ab6a61816143e3228705f69a3c15dfe91831a87c740b1f91c6d
|
|
BLAKE2b-256 checksum How to use checksums |
2da3a5df0565505c5756529c6963b129c5fe9f81852ec94a18acb7f157ae6fb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.15
|
Release files / fastapi_query_conditions-1.0.2-py3-none-any.whl
| Download URL | fastapi_query_conditions-1.0.2-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1528bfe897d9a6c717ee355054e2577e108c91bc8846271191efce1567fa4c8a
|
|
BLAKE2b-256 checksum How to use checksums |
f3329d81266fcfa0a75a26e1963dc5b0b1eecedab0607d80596d5c42e46a4d34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.15
|
Security for fastapi-query-conditions 1.0.2
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.