Skip to main content
Fetch any page and get data in the formats you choose using POST https://api.hyperbrowser.ai/x402/web/fetch. No Hyperbrowser account or API key is required. The price is calculated from your request options and returned in the payment requirements.

Fetch a page with TypeScript

The X402 SDKs handle the payment challenge, wallet signature, and retry automatically. This example supports both EVM and Solana wallets.

1. Install dependencies

2. Configure your wallet

Set either or both keys in a .env file. Use a 0x-prefixed EVM private key or a base58-encoded Solana 64-byte secret key, and fund the wallet with USDC on the network you intend to use.
Set only one key to choose EVM or Solana. With both set, the client uses the first compatible payment option returned by the server.

3. Fetch a page

Save this as fetch.ts. If your keys are in .env.agent, replace dotenv.config() with dotenv.config({ path: ".env.agent" }).
Run the example:

Request payment requirements

Send a fetch request to receive a 402 Payment Required response:
The PAYMENT-REQUIRED header contains base64-encoded JSON with the accepted networks, assets, amount, and recipient.

Sign and retry

Use your X402 client and wallet to generate a signed payment authorization from those requirements. Set PAYMENT_SIGNATURE to the encoded authorization returned by your client, then retry with the same request body:
The response contains the fetch status and requested outputs under data. The PAYMENT-RESPONSE header contains settlement information. See the X402 overview for the shared payment flow.
Each request returns the fetch result. To purchase a browser you can control directly, use Browser Sessions. See the Fetch API documentation for the full parameter reference and examples, and the X402 Fetch reference for payment headers and response schemas.