Get started with Book402 in under 5 minutes.
1. Browse (Free)¶
No setup needed — free endpoints work with any HTTP client:
# Search books by keyword
curl "https://book402.com/books?q=habits"
# Get a specific book
curl "https://book402.com/books/42"
# List all genres
curl "https://book402.com/genres"
# API stats
curl "https://book402.com/stats"
2. Pay for Deep Search¶
Paid endpoints use the x402 protocol. When you hit a paid endpoint without payment, you get a 402 Payment Required response with instructions:
curl -I "https://book402.com/search/hybrid?q=stoicism"
# HTTP/1.1 402 Payment Required
# PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbi... (base64 payment requirements)
3. Set Up an x402 Client¶
import { wrapFetchWithPayment, x402Client } from '@x402/fetch';
import { ExactEvmScheme, toClientEvmSigner } from '@x402/evm';
import { createWalletClient, createPublicClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { base } from 'viem/chains';
// Your wallet (NEVER hardcode in production!)
const account = privateKeyToAccount('0x...');
const transport = http('https://mainnet.base.org');
const publicClient = createPublicClient({ chain: base, transport });
const walletClient = createWalletClient({ account, chain: base, transport });
const signer = toClientEvmSigner(account, publicClient, walletClient);
// Create x402 client
const client = new x402Client();
client.register('eip155:8453', new ExactEvmScheme(signer));
const fetchWith402 = wrapFetchWithPayment(globalThis.fetch, client);
// Make a paid request — payment is automatic!
const res = await fetchWith402(
'https://book402.com/search/hybrid?q=stoicism&limit=5'
);
const data = await res.json();
console.log(data);
use x402_reqwest::X402ClientExt;
let client = reqwest::Client::new()
.with_payments(signer)
.prefer(USDCDeployment::by_network(Network::Base))
.max(USDCDeployment::by_network(Network::Base).amount("1.00")?)
.build();
let res = client
.get("https://book402.com/search/hybrid?q=stoicism")
.send()
.await?;
4. What You Need¶
| Requirement | Details |
|---|---|
| USDC on Base | Get USDC on Base L2 (Coinbase, Uniswap, bridge from Ethereum) |
| Wallet | Any EVM wallet with a private key (MetaMask export, or generate one) |
| ETH for gas | Tiny amount of ETH on Base for transaction fees (~$0.001) |
Cost
A hybrid search costs $0.01 USDC (~10,000 units). That's 100 searches for $1.
Architecture Overview¶
graph LR
A[Your Agent] -->|1. Request| B[Book402 API]
B -->|2. 402 + payment requirements| A
A -->|3. Signed payment + request| B
B -->|4. Verify| C[x402 Facilitator]
C -->|5. Valid ✅| B
B -->|6. Search results| A
B -->|7. Settle| C
C -->|8. USDC transfer| D[Base L2]