# WebExtract: minimal examples (Node 20+)

Two single-file examples that go from a free first call to a paid one.

```sh
npm install
node rest.mjs                      # REST, free try: X-Billing: free (20 calls/day per IP, no signup)
node rest.mjs --pay --dry-run      # read the x402 price from the 402 response; signs nothing
EVM_PRIVATE_KEY=0x... node rest.mjs --pay                       # pay one call: $0.002 USDC on Base (eip155:8453)
WEBEXTRACT_SANDBOX=1 EVM_PRIVATE_KEY=0x... node rest.mjs --pay  # same flow with Base Sepolia test USDC (/sandbox)
node mcp.mjs                       # MCP: initialize, tools/list, page_markdown (free tier, no header needed)
WEBEXTRACT_KEY=<api_key> node mcp.mjs   # MCP with a prepaid key (Authorization: Bearer)
```

- `rest.mjs` pays from your own wallet only. Use a low-balance wallet you control and never commit its key. Any payment above $0.01 is refused (per-payment cap).
- Test USDC for the sandbox: https://faucet.circle.com (Base Sepolia).
- Prepaid credits by card: https://webextract.dev/#pricing (the API key is shown once after payment).
- Optional env: `WEBEXTRACT_BASE` (default `https://api.webextract.dev`), `WEBEXTRACT_UA` (User-Agent, default `webextract-example-min/1`).
- REST errors are JSON and not charged. Full reference: https://webextract.dev/docs

MIT licensed, see https://webextract.dev/examples/LICENSE.txt
