Getting started with requests
Make x402 payments with a requests client 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 requests client
main.py
Step 4: Run the client
Your client is now making x402 payments!
Step 5: Test the client
You can test payments against a local server by running the fastapi example or the flask example from the x402 repository. Just set your environment variables to match your local server, install the dependencies, and run the examples.You can also test your client against PayAI’s live Echo Merchant for free. You will receive a full refund of any tokens that you send, and PayAI will pay for the network fees.
Need help?
Join our Community
Have questions or want to connect with other developers? Join our Discord server.