NutriRef — pay-per-call USDA nutrition for AI agents
Structured FoodData Central data behind x402 micropayments. No signup, no API keys, no auth flows — agents pay $0.001 – $0.005 per request in USDC on Base.
Endpoints
| Method | Path | Price | Returns |
|---|---|---|---|
| GET | /v1/nutrition/search?q=&limit= | $0.001 | Ranked food matches (fdc_id + macros) |
| GET | /v1/nutrition/detail/{fdc_id} | $0.002 | Full normalized nutrition (13 nutrients) |
| POST | /v1/nutrition/compare | $0.003 | 2–5 foods side by side + per-nutrient winners |
| POST | /v1/nutrition/recipe | $0.005 | Scaled + summed nutrition for a recipe |
How payment works
An x402-aware HTTP client handles it automatically. Unpaid requests return 402 Payment Required with payment instructions; the client signs a gasless USDC authorization (EIP-3009) and retries. The facilitator settles on-chain.
Call it from Python
from x402.client import x402Client
from x402.http.clients.httpx import wrapHttpxWithPayment
from x402.mechanisms.evm.exact import register_exact_evm_client
from eth_account import Account
import asyncio
account = Account.from_key("0x...your-funded-wallet-key...") # needs USDC on Base
client = x402Client(); register_exact_evm_client(client, account)
async def main():
async with wrapHttpxWithPayment(client, base_url="https://nutriref.xyz") as http:
r = await http.get("/v1/nutrition/detail/2012128")
print(r.json())
asyncio.run(main())
Network
Chain Base mainnet (chain id 8453)
Asset USDC — 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Receiver 0x3f0a7f839619D578b8EEeD741C26F418b8E98e97
Use it from Claude / MCP agents
NutriRef ships an MCP server wrapper. Any agent that speaks MCP (Claude Desktop, Claude Code, etc.) plugs it in with one config block:
{
"mcpServers": {
"nutriref": {
"command": "python",
"args": ["-m", "mcp_server"],
"env": {
"PAYER_PRIVATE_KEY": "0x...your-funded-wallet-key...",
"NUTRIREF_BASE_URL": "https://nutriref.xyz"
}
}
}
}
Source & install: github.com/Younghef/nutriref-api (pip install ".[mcp]").
Machine-readable
/openapi.json — full OpenAPI spec · /docs — Swagger UI · /.well-known/x402 — x402 Bazaar discovery · /llms.txt — LLM-readable summary · /.well-known/ai-plugin.json — AI plugin manifest