Skip to content

feat(python): add FastAPI and Flask x402 decorator - #18

Open
zhailong8845-art wants to merge 1 commit into
nirium-protocol:mainfrom
zhailong8845-art:codex/python-x402-decorator
Open

feat(python): add FastAPI and Flask x402 decorator#18
zhailong8845-art wants to merge 1 commit into
nirium-protocol:mainfrom
zhailong8845-art:codex/python-x402-decorator

Conversation

@zhailong8845-art

Copy link
Copy Markdown

Summary

  • add @x402_required(price="0.02") for FastAPI and Flask routes
  • read X-402-Signature, verify it with an x402 facilitator, and require successful settlement before calling the route
  • return HTTP 402 for missing or invalid payments
  • support async FastAPI handlers and synchronous Flask handlers
  • document settlement-address configuration and both framework integrations

Tests

  • pytest: 9 passed, including FastAPI and Flask test-client integration
  • ruff check: passed
  • mypy: passed
  • compileall: passed
  • Python sdist and wheel build: passed

A Starlette deprecation warning about its current httpx TestClient adapter is emitted by the external framework dependency; it does not affect the passing integration tests.

Closes #10

Bounty: GrantFox $25 USDC FastAPI Python x402 decorator bounty in #10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastAPI / Flask x402 decorator

1 participant