Back to Blog

x402 Protocol: How AI Agents Pay for Stock Signal Data

6 min readx402apiai-agents

AI agents need access to real-time data, but traditional API access models — API keys, OAuth flows, subscription plans — create friction that autonomous agents cannot easily navigate. The x402 protocol solves this by extending HTTP with a native payment layer: when an agent hits a monetized endpoint, it receives an HTTP 402 response with payment details, pays in USDC on Base (L2), and retries to receive the data. No registration, no API key, no subscription.

How x402 works

The x402 protocol builds on a familiar HTTP pattern. When an AI agent sends a GET request to a monetized endpoint (like /api/tickers/trending), the server responds with HTTP 402 Payment Required instead of 401 Unauthorized. The 402 response body includes the payment amount, the wallet address, the network (Base mainnet), and a payment scheme. The agent constructs a USDC transfer using EIP-3009 (transferWithAuthorization), attaches the payment proof as an X-PAYMENT header, and retries the request. The server verifies the payment through a facilitator and returns the data. The entire flow is atomic — you are only charged on successful responses.

Pricing: micropayments that make sense

SignalScope's x402 pricing reflects the value and cost of each endpoint. Signal data endpoints (trending tickers, individual ticker data, history, performance, related tickers) cost between $0.005 and $0.01 per call. AI-generated reports with trade setups cost $0.05, reflecting the AI inference cost. The search endpoint remains free — letting agents discover tickers before deciding which ones to pay for. These prices are designed for high-frequency automated access: an agent querying 20 tickers with reports would spend about $1.10.

USDC on Base: near-zero gas

Payments settle in USDC on Base, an Ethereum L2 network. Base offers near-zero gas fees (typically under $0.01 per transaction), making micropayments practical. The payment uses EIP-3009 transferWithAuthorization, which means the agent pre-authorizes a specific transfer amount to a specific address — there's no open-ended approval that could be exploited. The facilitator (hosted by Coinbase at facilitator.x402.org) validates the payment proof and confirms settlement.

Coexisting with traditional auth

x402 is an additional access method, not a replacement. SignalScope's endpoints support three auth methods: session cookies (web dashboard), API keys (programmatic access for registered users), and x402 micropayments (anonymous pay-per-call). If a request includes a session cookie, Bearer token, or API key, normal auth is used. Only requests without any credentials trigger the x402 flow. This means existing users are unaffected — x402 simply opens the API to agents that cannot or prefer not to register.

Building an x402-compatible agent

Any AI agent with access to a USDC wallet on Base can use x402. The workflow is: send a request, check for 402 status, parse the payment requirements from the response, sign a USDC transfer authorization, add it as an X-PAYMENT header, and retry. Libraries and SDKs for x402 are available at x402.org, with support for JavaScript/TypeScript, Python, and other languages. SignalScope also provides an Agent Skill document (at /skill/SKILL.md) that gives AI assistants all the context they need to interact with the API.