Installation
SDK Installation
npm install @atv-eth/x402-sdk viem
Requirements
- Node.js 18 or higher
viemas a peer dependency
Configuration
Basic Setup
import { ATVClient } from '@atv-eth/x402-sdk';
const client = new ATVClient({
privateKey: process.env.WALLET_KEY,
});
All Options
const client = new ATVClient({
// Required for paid requests
privateKey: process.env.WALLET_KEY,
// Optional: custom base URL (default: api.web3identity.com)
baseUrl: 'https://api.web3identity.com',
// Optional: request timeout in ms (default: 30000)
timeout: 30000,
});
Alternative: Direct HTTP
You can use the API without the SDK:
Using fetch
const response = await fetch('https://api.web3identity.com/api/ens/resolve/vitalik.eth');
const data = await response.json();
Using @x402/fetch
For automatic payment handling without our SDK:
npm install @x402/fetch
import { wrapFetch } from '@x402/fetch';
const x402Fetch = wrapFetch(fetch, {
privateKey: process.env.WALLET_KEY,
});
const res = await x402Fetch('https://api.web3identity.com/api/ens/resolve/vitalik.eth');
const data = await res.json();
TypeScript
Full type definitions are included:
import { ATVClient } from '@atv-eth/x402-sdk';
import type { ENSProfile, FarcasterUser } from '@atv-eth/x402-sdk';
const client = new ATVClient({
privateKey: process.env.WALLET_KEY!,
});
const profile: ENSProfile = await client.getProfile('vitalik.eth');
Next Steps
- First Request — Make your first SDK request
- SDK Methods — Full method reference