Call the recommendation engine directly via the REST API. All endpoints require an x402 payment header.
Crypto Data Endpoints
Live prices, market data, portfolios, and conversions.
GET /price?coin=bitcoin
GET /top10
GET /compare?coins=bitcoin,ethereum
GET /portfolio?coins=bitcoin:0.5,ethereum:2
GET /convert?from=bitcoin&to=ethereum&amount=1
$0.001 USDC per request
Quick Integration (Node.js)
// x402 client helper
async function x402Fetch(url, wallet, chainId = 8453) {
const res = await fetch(url);
if (res.status !== 402) return res;
const { accepts } = await res.json();
const req = accepts.find(a => a.scheme === 'exact');
const nonce = '0x' + [...crypto.getRandomValues(new Uint8Array(32))]
.map(b => b.toString(16).padStart(2, '0')).join('');
const validBefore = Math.floor(Date.now() / 1000) + req.maxTimeoutSeconds;
const typedData = {
domain: { name: req.extra.name, version: req.extra.version, chainId, verifyingContract: req.asset },
types: { TransferWithAuthorization: [
{ name: 'from', type: 'address' }, { name: 'to', type: 'address' },
{ name: 'value', type: 'uint256' }, { name: 'validAfter', type: 'uint256' },
{ name: 'validBefore', type: 'uint256' }, { name: 'nonce', type: 'bytes32' }
]},
primaryType: 'TransferWithAuthorization',
message: { from: wallet, to: req.payTo, value: req.maxAmountRequired,
validAfter: '0', validBefore: String(validBefore), nonce }
};
const sig = await window.ethereum.request({
method: 'eth_signTypedData_v4',
params: [wallet, JSON.stringify({ ...typedData, types: {
EIP712Domain: [
{ name: 'name', type: 'string' }, { name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' }, { name: 'verifyingContract', type: 'address' }
], ...typedData.types
}})]
});
const payment = btoa(JSON.stringify({
x402Version: 1, scheme: req.scheme, network: req.network,
payload: { signature: sig, authorization: typedData.message }
}));
return fetch(url, { headers: { 'X-PAYMENT': payment } });
}