Catalog PyPI
PACKAGE EXPLORERView in registry

actiongate-fastapi

PyPI

Gate FastAPI routes through ActionGate primitives.

actiongateai-agentsfastapimiddlewarerate-limiting
Versions collected1
Direct dependencies7From release 0.1.0
Last observed20 Oct, 18:32 UTC

README

Version 0.1.0 documentation

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.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.015 Mar 20267

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
actiongate-oss/actiongate-fastapi

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:32 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:f906d5d6d6f4bd6e9d6a681f31adf28fe8bf414191c4a729e3684c53e41a9984