Pay-per-call trading signal API lets AI agents pay with USDC micropayments
Developer pmestre-Forge built a trading signal API where AI agents pay per call using the x402 protocol and USDC micropayments on Base L2 — no signup or API keys required.
Score breakdown
Developers building autonomous trading agents can fork this open-source template to implement pay-per-call monetization via USDC micropayments, bypassing the human-centric API key and subscription flows that block fully autonomous agent workflows.
- 01Uses the x402 protocol, which revives the HTTP 402 'Payment Required' status code for autonomous agent payments
- 02Agents pay in USDC micropayments on Base L2 — no signup or API keys required
- 03Full payment-to-data flow completes in ~200ms
pmestre-Forge built a trading signal API that replaces traditional API key authentication and subscription billing with autonomous micropayments, targeting AI agents that need market data without human intervention. The system uses the x402 protocol, which revives the long-dormant HTTP 402 "Payment Required" status code: an agent calls an endpoint, receives a 402 response with payment instructions, signs a USDC transfer on Base L2 via its wallet, retries the request with a payment proof header, and the server verifies the payment through a Coinbase facilitator before returning data. The entire round-trip takes approximately 200ms.
The API exposes three endpoints: `/signal/TICKER` at $0.005 per call returns a single stock signal, `/scan/momentum` at $0.01 returns the top 10 momentum setups, and `/risk` at $0.01 delivers portfolio risk analysis.
The API exposes three endpoints: `/signal/TICKER` at $0.005 per call returns a single stock signal, `/scan/momentum` at $0.01 returns the top 10 momentum setups, and `/risk` at $0.01 delivers portfolio risk analysis. Each signal is a composite momentum score built from RSI (14) for oversold/overbought detection, ADX (14) for trend strength (values above 25 indicate a strong trend), MACD (12/26/9) for crossover and direction, and a volume ratio comparing current volume to the 20-day average. Scores map to BUY (>=30), SELL (<=-30), or HOLD, accompanied by a confidence value from 0 to 1.
The stack uses FastAPI with synchronous endpoints to handle `yfinance` blocking I/O, the x402 Python SDK with ASGI middleware, an LRU cache with 200 entries and a 5-minute TTL, and is deployed on Fly.io. The project is open source on GitHub and is explicitly framed as a forkable template for developers looking to build monetized services for the emerging AI agent economy.
Key facts
- 01Uses the x402 protocol, which revives the HTTP 402 'Payment Required' status code for autonomous agent payments
- 02Agents pay in USDC micropayments on Base L2 — no signup or API keys required
- 03Full payment-to-data flow completes in ~200ms
- 04Composite signal is built from RSI (14), ADX (14), MACD (12/26/9), and a 20-day volume ratio
- 05Three endpoints: /signal/TICKER ($0.005), /scan/momentum ($0.01), and /risk ($0.01)
- 06Stack: FastAPI, x402 Python SDK with ASGI middleware, LRU cache (200 entries, 5-min TTL), deployed on Fly.io
- 07Project is open source on GitHub and framed as a forkable template for AI agent economy services