Barcode product lookup
GET /api/barcode-lookup · Cached 1dLook up a product by its UPC/EAN barcode number via Open Food Facts (open data): name, brand, category, quantity, and nutrition grade. Send GET /api/barcode-lookup with the required field code and pay $0.005 per call over x402 or MPP (there is no free tier). It returns a JSON object with code, found and product.
Pairs with /api/barcode-decode (image → number → product). ?code=737628064502
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
code | string | yes | UPC/EAN barcode digits (8-14) Also accepted as source, src, barcode, upc, ean, gtin. |
Example request
curl -i "https://agent402.tools/api/barcode-lookup?code=737628064502"
Without payment this returns HTTP 402 Payment Required with the exact price for barcode-lookup; any x402 v2 or MPP client pays it and retries.
Example response
{
"code": "737628064502",
"found": true,
"product": {
"name": "Thai peanut noodle kit",
"brands": "Simply Asia",
"categories": "Meals",
"quantity": "155 g",
"nutritionGrade": "d",
"countries": "United States"
}
}
| Field | Type | Always present | In the example |
|---|---|---|---|
code | string | yes | 737628064502 |
found | boolean | yes | true |
product | object | yes | 6 fields: name, brands, categories, quantity, nutritionGrade, countries |
From an MCP client
catalog.call {
"slug": "barcode-lookup",
"params": {
"code": "737628064502"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for barcode-lookup; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
codeis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - Cached: an identical request within 1d is answered from cache with
X-Cache: hit. - A
POSTwith a JSON body to /api/barcode-lookup is served as this GET, with the body as the input. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/barcode-lookup?code=737628064502");
Related tools
Barcode / QR decode
POST /api/barcode-decodeDecode a barcode or QR code from an image. Send a base64 PNG or JPEG (or a data: URL); returns the decoded text and the …
EDGAR company lookup (ticker → CIK)
GET /api/edgar-company-lookupResolve a US stock ticker (e.g. AAPL) to its SEC CIK number, the primitive every other EDGAR call needs. Returns ticker,…
A2A Agent Card validate
POST /api/a2a-card-validateValidate an A2A (Agent2Agent protocol) Agent Card: required fields, skill shape, transport names, capability flags - spe…
Amortization schedule
POST /api/amortizationBuild the full per-period amortization schedule for a fully-amortizing loan. Each row reports the period number, payment…
Annuity present/future value
POST /api/annuityPresent and future value of a level annuity (equal periodic payments). Supports an ordinary annuity (payments at period …
Black-Scholes option price
POST /api/black-scholesPrice a European option (call or put) with the Black-Scholes-Merton model, plus the greeks (delta, gamma, vega, theta, r…