2s
Latest reading of a curated US macroeconomic indicator, with the prior + year-ago values and YoY % change. Pass indicator for one, or omit for all. Indicators: unemployment-rate, fed-funds-rate, nonfarm-payrolls, jobless-claims, labor-force-participation, real-gdp, gdp-growth, 10y-treasury, 2y-treasury, 3m-treasury, 30y-mortgage, consumer-sentiment, housing-starts, retail-sales, industrial-production, m2, personal-saving-rate — i.e. unemployment rate, fed funds rate, nonfarm payrolls, jobless claims, labor-force participation, real GDP + GDP growth, 2y/3m/10y Treasury yields, 30y mortgage rate, consumer sentiment, housing starts, retail sales, industrial production, M2, personal saving rate. Each result names the FRED series ID + units. Source: BLS/BEA/Fed/Treasury via FRED (St. Louis Fed). For inflation specifically use inflation.rates; for any raw series use bls.series.
HTTP 402 with machine-readable payment
terms, your agent pays the $0.0014 USDC in USDC on-chain, and retries automatically. Pays to 0x2b6D4988Db4723E6908Db86Ab2b8dFBc51FC32C5.Call it in 30 seconds
// npm i x402-fetch viem
import { wrapFetchWithPayment } from "x402-fetch";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";
const account = privateKeyToAccount(process.env.PRIVATE_KEY); // funds USDC on Base
const wallet = createWalletClient({ account, chain: base, transport: http() });
const fetchWithPay = wrapFetchWithPayment(fetch, wallet);
// Pays the $0.0014 USDC automatically on the 402, then returns the real response:
const res = await fetchWithPay("https://2s.io/api/econ/indicator", { method: "GET" });
console.log(await res.json());
# pip install x402 eth-account httpx
import os, asyncio
from eth_account import Account
from x402.clients.httpx import x402HttpxClient
account = Account.from_key(os.environ["PRIVATE_KEY"]) # funds USDC on Base
async def main():
async with x402HttpxClient(account=account) as client:
# x402 handles the 402 -> pay ($0.0014 USDC) -> retry automatically
r = await client.get("https://2s.io/api/econ/indicator")
print((await r.aread()).decode())
asyncio.run(main())
# 1) An unpaid request returns HTTP 402 with the exact payment terms: curl -i "https://2s.io/api/econ/indicator?indicator=unemployment-rate" # 2) Paying + retrying requires an x402 client that can sign the USDC # authorization (curl alone cannot). See the JS / Python tabs below.
New to x402? Read the 5-minute quickstart →