actiongate-fastapi
Gate FastAPI routes through ActionGate primitives.
pip install actiongate-fastapi
Route decorator
from fastapi import FastAPI
from actiongate import Engine, Gate, Policy
from actiongate_fastapi import gated_route
app = FastAPI()
ag = Engine()
@app.post("/search")
@gated_route(
actiongate=ag,
gate=Gate("api", "search", "global"),
policy=Policy(max_calls=100, window=60),
)
async def search(query: str):
return {"results": do_search(query)}
Returns 429 for rate limit and budget blocks. Returns 403 for policy violations.
Dependency injection
from fastapi import Depends
from actiongate_fastapi import gate_dependency
require_gate = gate_dependency(actiongate=ag)
@app.post("/search")
async def search(
query: str,
_=Depends(require_gate(
gate=Gate("api", "search"),
policy=Policy(max_calls=100, window=60),
)),
):
return {"results": do_search(query)}
Add more gates
pip install actiongate-fastapi[all]
from actiongate import Engine as AG, Gate, Policy
from budgetgate import Engine as BG, Ledger, Budget
from rulegate import Engine as RG, Rule, Ruleset, Context
from actiongate_fastapi import gated_route
from decimal import Decimal
ag, bg, rg = AG(), BG(), RG()
def no_pii(ctx: Context) -> bool:
return "ssn" not in str(ctx.kwargs).lower()
@app.post("/search")
@gated_route(
actiongate=ag,
gate=Gate("api", "search", "global"),
policy=Policy(max_calls=100, window=60),
budgetgate=bg,
ledger=Ledger("api", "search", "global"),
budget=Budget(max_spend=Decimal("50.00"), window=3600),
cost=Decimal("0.01"),
rulegate=rg,
rule=Rule("api", "search"),
ruleset=Ruleset(predicates=(no_pii,)),
)
async def search(query: str):
return {"results": do_search(query)}
Gates evaluate in order: ActionGate → BudgetGate → RuleGate → execute → AuditGate.
License
Apache-2.0. ActionGate and BudgetGate are Apache-2.0. RuleGate and AuditGate are BSL-1.1.
Metadata
Release files for actiongate-fastapi 0.1.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 |
|---|---|---|---|---|
| actiongate_fastapi-0.1.0.tar.gz | 8.9 kB | Without provenance | Details for actiongate_fastapi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| actiongate_fastapi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for actiongate_fastapi-0.1.0-py3-none-any.whl |
Total release size: 17.2 kB
Release files / actiongate_fastapi-0.1.0.tar.gz
| Download URL | actiongate_fastapi-0.1.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2547f40148c2d865af5dd8c151fe2c3b77c763e7337db4c415c88dda6a8f0b10
|
|
BLAKE2b-256 checksum How to use checksums |
a91fb4af7a37d1d5920e5eb3752a104f04b1fa49eee1085be71d97b2e5e966ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / actiongate_fastapi-0.1.0-py3-none-any.whl
| Download URL | actiongate_fastapi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
597a131413ab22aceec1904f0768ce6dca96d59c1403238323b4e05fc7aaf9f6
|
|
BLAKE2b-256 checksum How to use checksums |
8320bfcbec31846356a4bf1e2d063c4f4b162787d45cb1f60b35e1600065444b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for actiongate-fastapi 0.1.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.