How to give your AI agent live Amazon prices
Language models know a lot about products, but nothing about today's price. Ask an assistant whether a $24.99 blender is a good deal and it can only guess. To answer properly it needs live data: the current buy box price, what the product usually sells for, and whether today's price is unusually low or high.
This guide shows how to give an agent that data with ASIN402, an API built for agents: there is no account to create and no API key to manage. Each request is paid individually, in USDC on Base, through the x402 protocol.
How it works in one picture
- Your agent calls an endpoint, for example
GET /api/deal-check?asin=0735211299. - The server answers HTTP 402 Payment Required with the exact price in a
PAYMENT-REQUIREDheader. - Your x402 client signs a USDC payment for that amount and retries the same request.
- The server returns JSON. If the request fails (bad ASIN, no data), the payment is never settled, so failed calls cost nothing.
Steps 2 and 3 are handled for you by an x402 client library, so in practice your code looks like a normal fetch.
What you need
- Node.js 20 or newer.
- A wallet private key for the agent. Use a dedicated wallet, not your main one, and fund it with a few dollars of USDC on the Base network. A typical lookup costs between $0.005 and $0.10.
Install the client packages:
npm install @x402/fetch @x402/evm viem
Your first paid call
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.AGENT_KEY);
const client = new x402Client().register("eip155:*", new ExactEvmScheme(account));
const pay = wrapFetchWithPayment(fetch, client);
const res = await pay("https://asin402.com/api/deal-check?asin=0735211299");
const deal = await res.json();
console.log(deal.verdict, deal.current_price, deal.avg_90d, deal.reason);
// e.g. buy_now 13.79 16.43 "Price is 16% below its 90-day average."
That single call costs $0.02. The response includes the current price, the 30, 90 and 180-day averages, the typical price range over 180 days with outlier offers filtered out, and a verdict:
| Verdict | Meaning |
|---|---|
buy_now |
Clearly below the usual price, or at the low end of its range |
fair_price |
Within the normal range |
wait |
Noticeably above its 90-day average; it usually comes back down |
verify_offer |
Far below the normal range: could be a glitch or an unreliable seller |
Turning it into an agent tool
Most agent frameworks let you register tools as functions with a description. Wrap the call so the model can use it whenever a user asks about a product:
const tools = [{
name: "check_amazon_deal",
description: "Check whether an Amazon product's current price is a good deal. Input: a 10-character ASIN.",
parameters: { type: "object", properties: { asin: { type: "string" } }, required: ["asin"] },
run: async ({ asin }) => (await pay(`https://asin402.com/api/deal-check?asin=${asin}`)).json(),
}];
If you only have a product name, search first and pick the right ASIN:
const found = await (await pay("https://asin402.com/api/data/search?term=insulated+water+bottle&history=0")).json();
const asin = found.products[0].asin;
Other useful endpoints
| Question your agent gets | Endpoint | Price |
|---|---|---|
| "What does this cost right now, and how well does it sell?" | /api/product?asin= |
$0.005 |
| "Is this a good deal?" | /api/deal-check?asin= |
$0.02 |
| "Show me the full price history" | /api/data/product?asin=&series=BUY_BOX_SHIPPING |
from $0.005 |
| "Compare these 20 products" | /api/data/product?asin=A,B,C,...&history=0 (up to 100 per call) |
from $0.005 |
All endpoints accept domain for other marketplaces: uk, de, fr, jp, ca, it, es, in, mx and br (default us). Responses use plain JSON with prices in currency units and ISO dates, so the model can read them directly.
Keeping spending under control
The x402 client refuses any single payment above $1 by default, which is far above the price of a normal lookup. Two more habits keep costs predictable:
- Batch. One
/api/data/productcall with 50 ASINs is one payment instead of 50. - Drop history you don't need. Add
history=0when you only need current values; responses are smaller and faster.
Next steps
- Build an FBA product research agent
- Use ASIN402 inside Claude or Cursor without writing code
- Full endpoint reference: /llms.txt and /openapi.json