Quick start
1
Install dependencies
2
Create a session
Run the following with your wallet’s private key (requires USDC on Base):
API reference
Create session
Creates a new browser session with prepaid time.- First Response (402)
- With Payment (200)
When you first make a request, you’ll receive a 402 Payment Required response with payment details:
Get session status
Check the status of an active session.Extend session
Add more time to an active session.Extending a session requires another x402 payment for the additional time.
Terminate session
End a session early. Unused time may be eligible for refund.Making x402 payments
- x402 Package (Recommended)
- x402-fetch (Automatic)
Use the x402 package for full control over the payment flow:
Node.js
Using your session
Once you have aconnectUrl, connect with Playwright or Puppeteer:
Expected output
The paid create-session request returns session details includingconnectUrl. Connecting through Playwright or Puppeteer opens that browser. Keep the connection URL private because it provides access to the session.
Cleanup
Close the browser connection and callPOST /browser/session/:id/terminate for the session you created. Check that the response reports finalStatus: "terminated". Review the termination response for usage and any refund information rather than assuming an early exit refunds the payment.
Further reading
x402 Protocol
Learn about the x402 payment protocol
Get USDC on Base
Bridge or swap tokens to get USDC on Base