Getting started with FastAPI
Start accepting x402 payments in your FastAPI server in 2 minutes.You can find the full code for this example here.
Step 1: Install dependencies
Step 2: Set your environment variables
.env
file should look like this:
Step 3: Create a new FastAPI app
main.py
Step 4: Run the server
Your server is now accepting x402 payments!
Step 5: Test the server
You can test payments against your server locally by following the httpx example or the requests example from the x402 repository. Just set your environment variables to match your local server, install the dependencies, and run the examples.Need help?
Join our Community
Have questions or want to connect with other developers? Join our Discord server.