Two ways to access premium features: subscribe with an API key, or pay per request with USDC.
No subscription needed. Pay only for what you use, instantly settled on-chain via the x402 protocol.
402 Payment Required response with payment details.X-PAYMENT header. Your request is served instantly.npm install @x402/fetch @x402/evm viemClick to copyimport { x402Client, wrapFetchWithPayment } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm/exact/client';
import { privateKeyToAccount } from 'viem/accounts';
// Setup wallet (use env var, never hardcode)
const signer = privateKeyToAccount(process.env.WALLET_KEY);
// Create x402 client
const client = new x402Client();
client.register('eip155:*', new ExactEvmScheme(signer));
const paidFetch = wrapFetchWithPayment(fetch, client);
// Call any premium endpoint — payment handled automatically
const res = await paidFetch('https://ipfast.dev/json/8.8.8.8');
const data = await res.json();
console.log(data.country, data.city);
pip install "x402[httpx]" eth-accountClick to copyimport os
from x402 import x402Client
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client
from x402.http.clients import x402HttpxClient
from eth_account import Account
# Setup wallet
account = Account.from_key(os.environ["WALLET_KEY"])
# Create x402 client
client = x402Client()
register_exact_evm_client(client, EthAccountSigner(account))
# Call any premium endpoint — payment handled automatically
async with x402HttpxClient(client) as http:
res = await http.get("https://ipfast.dev/json/8.8.8.8")
data = res.json()
print(data["country"], data["city"])
go get github.com/coinbase/x402/goClick to copypackage main
import (
"encoding/json"
"fmt"
"net/http"
x402 "github.com/coinbase/x402/go"
"github.com/coinbase/x402/go/evm"
)
func main() {
// Create x402 client with wallet
client := x402.Newx402Client()
client.Register("eip155:*", evm.NewExactEvmScheme(privateKey))
httpClient := x402.WrapHTTPClientWithPayment(
http.DefaultClient, client,
)
// Call any premium endpoint — payment handled automatically
resp, _ := httpClient.Get(
"https://ipfast.dev/json/8.8.8.8",
)
defer resp.Body.Close()
var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
fmt.Println(data["country"], data["city"])
}
curl -H "X-API-Key: sk_live_xxx" https://ipfast.dev/json/8.8.8.8Click to copy# Option 1: Use an API key (simplest, no wallet needed)
curl -H "X-API-Key: sk_live_your_key_here" https://ipfast.dev/json/8.8.8.8
# Option 2: Pay per request with x402
# Step 1 — Get payment requirements:
curl -s https://ipfast.dev/json/8.8.8.8
# Returns 402 with price, wallet, and network details
# Step 2 — Sign payment with x402 SDK and retry:
curl -H "X-PAYMENT: <base64-signed-payload>" https://ipfast.dev/json/8.8.8.8
# Free endpoints (free API key required -- register at ipfast.dev/login):
curl https://ipfast.dev/json # Your own IP
curl https://ipfast.dev/country # Your country code
curl https://ipfast.dev/city # Your city
Connect your wallet and make a real API call. Payment is handled automatically.