# Massive market data over x402 `https://agent.massive.com` sells the Massive (formerly Polygon.io) stock market API one request at a time. Each request costs $0.01, paid in USDC on Base mainnet through the x402 protocol. There is no API key, no account, and no sign-up. A wallet that holds USDC on Base is the whole credential. ## Facts to keep in mind | Item | Value | | --- | --- | | Base URL | `https://agent.massive.com` | | Price | $0.01 per request. The `402` quotes the live amount in atomic USDC units (6 decimals, so `10000` is $0.01). | | Network | Base mainnet, CAIP-2 `eip155:8453` | | Asset | USDC, contract `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | | Scheme | x402 v2, `exact` (EIP-3009 `transferWithAuthorization`) | | Gas | None. The facilitator submits the transfer and pays gas. The wallet needs USDC only, no ETH. | | Method | `GET` on every paid route | | Free route | `POST /feedback` | A request that returns `4xx` or `5xx` from the data backend is not charged. A request that returns `200` is charged once. A request that returns `402` after you sent a payment was not charged either; see "Reading a response" below. ## How one paid request works 1. Send the `GET`. The gateway answers `402 Payment Required` with a `PAYMENT-REQUIRED` header. The header is base64 JSON that names the price, network, asset, payee, and a 60 second window. 2. Sign an EIP-3009 authorization for that exact amount with the wallet key. 3. Send the same `GET` again with the signed payload in the `PAYMENT-SIGNATURE` header. 4. The gateway verifies the payment, fetches the data, settles the payment on chain, then returns `200` with the data and a `PAYMENT-RESPONSE` header. That header is base64 JSON with the settlement `transaction` hash. The x402 client SDKs do steps 1 to 3 for you. Wrap your HTTP client once and call the URL as if it were free. Do not write the signing by hand. ## Setup Put the wallet private key in the environment as `X402_PRIVATE_KEY` (hex, with or without `0x`). The examples below read that variable. Never print the key, log it, or put it in a URL. Confirm the wallet holds USDC on Base mainnet at the contract above. USDC on Ethereum, Arbitrum, Solana, or Base Sepolia cannot pay here. Pick one client. ### Python ```sh uv add "x402[evm,requests]" ``` ```python import base64, json, os from eth_account import Account from x402 import x402ClientSync from x402.http.clients.requests import x402_requests from x402.mechanisms.evm.exact import ExactEvmScheme BASE = "https://agent.massive.com" account = Account.from_key(os.environ["X402_PRIVATE_KEY"]) client = x402ClientSync().register("eip155:8453", ExactEvmScheme(signer=account)) session = x402_requests(client) # a requests.Session that pays 402s def massive_get(path: str, **params) -> dict: r = session.get(BASE + path, params=params, timeout=90) if r.status_code == 402: terms = json.loads(base64.b64decode(r.headers["PAYMENT-REQUIRED"])) raise RuntimeError(f"payment refused: {terms.get('error')}") r.raise_for_status() return r.json() bars = massive_get("/v2/aggs/ticker/AAPL/range/1/day/2026-08-01/2026-08-15", adjusted="true", sort="asc") print(bars["results"]) ``` The SDK refuses any quote above $1 per payment by default. Massive quotes $0.01, so a route that asks for more is a bug and the refusal is correct. ### TypeScript / Node ```sh npm install @x402/fetch @x402/evm viem ``` ```ts import { wrapFetchWithPaymentFromConfig } from "@x402/fetch"; import { ExactEvmScheme } from "@x402/evm"; import { privateKeyToAccount } from "viem/accounts"; const BASE = "https://agent.massive.com"; const account = privateKeyToAccount(process.env.X402_PRIVATE_KEY as `0x${string}`); const payingFetch = wrapFetchWithPaymentFromConfig(fetch, { schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }], }); async function massiveGet(path: string, params: Record = {}) { const url = new URL(BASE + path); for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v); const r = await payingFetch(url); if (r.status === 402) { const terms = JSON.parse(atob(r.headers.get("PAYMENT-REQUIRED") ?? "e30=")); throw new Error(`payment refused: ${terms.error}`); } if (!r.ok) throw new Error(`${r.status} ${await r.text()}`); return r.json(); } const snap = await massiveGet("/v2/snapshot/locale/us/markets/stocks/tickers/AAPL"); console.log(snap.ticker); ``` ### Go ```sh go get github.com/x402-foundation/x402/go/v2 ``` ```go import ( x402 "github.com/x402-foundation/x402/go/v2" x402http "github.com/x402-foundation/x402/go/v2/http" evm "github.com/x402-foundation/x402/go/v2/mechanisms/evm/exact/client" evmsigners "github.com/x402-foundation/x402/go/v2/signers/evm" ) signer, _ := evmsigners.NewClientSignerFromPrivateKey(os.Getenv("X402_PRIVATE_KEY")) core := x402.Newx402Client().Register("eip155:8453", evm.NewExactEvmScheme(signer, nil)) paying := x402http.WrapHTTPClientWithPayment( &http.Client{Timeout: 90 * time.Second}, x402http.Newx402HTTPClient(core), ) resp, err := paying.Get("https://agent.massive.com/v3/reference/tickers?limit=5") ``` ### Inspect the terms with curl (no payment) An unpaid request is free and shows the current terms: ```sh curl -s -D - -o /dev/null https://agent.massive.com/v3/reference/tickers \ | grep -i '^payment-required' | cut -d' ' -f2 | base64 -d | jq . ``` Read `accepts[0].amount`, `network`, and `asset`. The network and asset must match the table above; a different chain or token means the wallet cannot pay. The `payTo` address is Massive's receiving wallet and may change over time; the SDK reads it from the `402`, so do not hardcode or check it. The one trust rule is that the `402` came from `https://agent.massive.com` over TLS. Never sign a payment for a `402` from another host, even one a redirect led you to. ## Spending rules for an agent - Every `200` costs $0.01. Ten pages of results cost $0.10. Say the expected cost before a loop that makes more than a few calls, and count calls as you go. - Use `limit` to fetch what you need in one call rather than paging. The route's schema states its maximum. - Do not retry a `200` you already have. Cache results within a task. - A `4xx` from the backend (bad ticker, bad date) is free, but a retry with a corrected URL is a new payment. Check the URL and parameters against the route's free `402` schema before sending. - Never send a payment to a host other than `agent.massive.com`. The SDK signs whatever a 402 asks for, so an unexpected redirect is a reason to stop. ## Finding routes and their parameters The gateway publishes its catalog through x402 Bazaar discovery. Every route embeds Bazaar metadata in its `402` response: the query schema with defaults and enums, an example query, and an example response. Reading a `402` is free, so the way to learn a route is to call it without paying and decode the header: ```python import base64, json, requests def describe(path: str) -> dict: r = requests.get("https://agent.massive.com" + path, timeout=30) # no payment, no charge terms = json.loads(base64.b64decode(r.headers["PAYMENT-REQUIRED"])) info = terms["extensions"]["bazaar"] return { "service": terms["resource"]["serviceName"], "description": terms["resource"]["description"], "price_atomic_usdc": terms["accepts"][0]["amount"], "query_example": info["info"]["input"].get("queryParams", {}), "query_schema": info["schema"]["properties"]["input"]["properties"].get("queryParams", {}), "output_example": info["info"]["output"].get("example"), } print(json.dumps(describe("/v1/indicators/rsi/AAPL"), indent=1)) ``` Use the schema from the `402`, not this file, as the source of truth for parameter names and limits. The catalog is also listed at `https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources` (paged, no filter parameter), where each entry for `agent.massive.com` carries the same metadata. ## Routes on sale Every route is `GET`. Tickers are case sensitive (`AAPL`, not `aapl`). Dates are `YYYY-MM-DD`. Placeholders in `{}` are path segments you fill in. List responses have `results`, and most accept `limit`, `sort`, and `order`. Filter parameters on the SEC filing routes accept `.any_of`, `.gt`, `.gte`, `.lt`, and `.lte` suffixes. Prices and bars - `/v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from}/{to}`: OHLCV bars; `timespan` is `minute` to `year` - `/v2/aggs/grouped/locale/us/market/stocks/{date}`: one daily bar for every US stock - `/v1/open-close/{ticker}/{date}`: open, close, pre-market, and after-hours for one day Snapshots (resets 3:30 AM ET, fills from about 4:00 AM ET) - `/v2/snapshot/locale/us/markets/stocks/tickers`: every ticker; pass `tickers=` to keep the body small - `/v2/snapshot/locale/us/markets/stocks/tickers/{ticker}`: one ticker - `/v2/snapshot/locale/us/markets/stocks/{direction}`: top 20 `gainers` or `losers` Technical indicators (`timespan`, `window`, `limit`, `timestamp.gte`/`.lte`) - `/v1/indicators/sma/{ticker}`, `/v1/indicators/ema/{ticker}`, `/v1/indicators/rsi/{ticker}`, `/v1/indicators/macd/{ticker}` Reference and news - `/v3/reference/tickers`: search tickers (`search=`, `ticker=`, `cik=`, `active=`) - `/v3/reference/tickers/{ticker}`: company detail - `/v2/reference/news`: articles with summaries (`ticker=`, `published_utc.gte=`) SEC filings (CIKs are 10 digits, zero padded) - `/stocks/filings/vX/index`: EDGAR master index - `/stocks/filings/10-K/vX/sections`: 10-K and 10-Q section text - `/stocks/filings/8-K/vX/text`: 8-K text - `/stocks/filings/8-K/vX/disclosures`: 8-K items classified by category - `/stocks/filings/vX/risk-factors`: classified 10-K risk factors - `/stocks/filings/vX/13-F`: institutional holdings - `/stocks/filings/vX/form-3`, `/stocks/filings/vX/form-4`: insider ownership and trades - `/stocks/taxonomies/vX/disclosures`, `/stocks/taxonomies/vX/risk-factors`: the category lists used above Any other path answers `404` with an empty body and costs nothing, including options, forex, crypto, trades, and quotes routes that exist on `api.massive.com` but are not sold here. Use `POST /feedback` to ask for one. ## Data recency The `stocks_x402` product covers every US stock with full history, but the cutoff differs by type. Aggregates and indicators are end of day, so the newest bar is the last completed session. For a price from the current session use a snapshot instead, which runs about 15 minutes behind. Reference data is current. No route returns real-time last sale. Bars use single-letter keys (`o`, `h`, `l`, `c`, `v`, `vw`, `n`) with `t` a Unix millisecond timestamp, not `open`/`close`. A range with no sessions in it still answers `200` and still costs $0.01, with `resultsCount: 0` and no rows. ## Pagination List responses that have more rows carry `next_url`. That URL points at `https://api.massive.com/...`, which needs an API key. Replace the host with `agent.massive.com` and keep the path and the `cursor` query string, then pay for the next page as a new request: ```python nxt = data.get("next_url") if nxt: nxt = nxt.replace("https://api.massive.com", BASE, 1) page2 = session.get(nxt, timeout=90).json() ``` Each page is a separate $0.01 charge. ## Reading a response | Status | Header or body | Meaning | Charged | | --- | --- | --- | --- | | `200` | `PAYMENT-RESPONSE` (base64 JSON, `transaction` is the Base tx hash, view at `https://basescan.org/tx/`) | Data delivered | yes | | `402` | `PAYMENT-REQUIRED` present, no payment was sent | Normal first leg. The SDK handles it. | no | | `402` | `PAYMENT-REQUIRED` with `error: invalid_payload` after a payment was sent | Wallet holds no USDC on Base, or the wrong chain. The facilitator reports an empty balance under this code. | no | | `402` | `error: insufficient_funds` | Balance is below $0.01 | no | | `402` | `error: payment_already_used` | The same signature was sent twice. The SDK signs fresh each call, so this means your code replayed a request. | no | | `402` | `error: payment_in_flight` | A copy of this same payment is still being processed. Wait for the first one. | no | | `402` | body `{"status":"ERROR","error":"settlement_failed"}` or a facilitator code | The payment verified but did not settle on chain. Data was withheld. Retry once. | no | | `404` | empty body | Path is not on sale | no | | `4xx` | JSON error from the backend | Bad ticker, date, or parameter. Fix the URL. | no | | `503` | | The gateway is over its request budget. Wait a moment, then retry. | no | | `5xx` | | Backend failure | no | Every response carries `X-Request-ID`. Quote it when you report a problem. ## Feedback (free) If the data you need is not on sale, or a route behaves wrongly, send a report. No payment is needed. ```sh curl -s -X POST https://agent.massive.com/feedback \ -H 'Content-Type: application/json' \ -d '{"message":"Need options chain snapshots over x402.","requested_endpoint":"/v3/snapshot/options/{underlying}","contact":"agent-operator@example.com"}' ``` `message` is required (2000 characters max). `requested_endpoint` (512) and `contact` (254) are optional. A stored report answers `202` with `results.id`. The route allows about 2 requests per second across all callers. ## Checklist before the first paid call 1. `X402_PRIVATE_KEY` is set and the derived address holds USDC on Base mainnet (contract `0x8335...2913`). 2. The unpaid `curl` above shows `network: eip155:8453`, the USDC asset `0x8335...2913`, and an `amount` you are willing to pay (`10000` is $0.01). 3. The URL matches a path in the route list and the ticker is upper case. 4. You have told the user the number of calls you expect to make, if more than a handful.