Skip to content

Docs

Every feed is served at https://api.realtimeapi.ai/v1/{feed}/{path}. Pay per request with x402, or use a key.

Pay with x402 in 3 lines

x402 turns HTTP 402 into a payment step. The client signs a USDC transfer authorization (EIP-3009) on Base and retries; the gateway settles only after the provider returns a 2xx.

TypeScript · @x402/fetch
// npm i @x402/fetch @x402/core @x402/evm viem
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = x402Client.fromConfig({ schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(privateKeyToAccount(PRIVATE_KEY)) }] });
const pay = wrapFetchWithPayment(fetch, client);
const data = await (await pay("https://api.realtimeapi.ai/v1/cryptodata/market-health")).json();
console.log(data);
Python · x402
# pip install x402 eth-account requests
from eth_account import Account
from x402.clients.requests import x402_requests

session = x402_requests(Account.from_key(PRIVATE_KEY))
print(session.get("https://api.realtimeapi.ai/v1/cryptodata/market-health").json())
curl
# 1. No key, no payment: the gateway answers 402 with the price
curl -i "https://api.realtimeapi.ai/v1/cryptodata/market-health"

# 2. Pay: retry with a signed x402 payment (any x402 client builds this header)
curl "https://api.realtimeapi.ai/v1/cryptodata/market-health" -H "PAYMENT-SIGNATURE: $X402_PAYMENT"

The 402 challenge

An unpaid request returns 402 Payment Required with a base64 PAYMENT-REQUIRED header (x402 v2) and the same object in the body, plus alternatives:

402 body
{
  "x402Version": 2,
  "error": "payment_required",
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "price": "$0.010",
      "payTo": "0x…treasury",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "maxTimeoutSeconds": 60,
      "resource": "https://api.realtimeapi.ai/v1/cryptodata/market-health",
      "mimeType": "application/json"
    }
  ],
  "alternatives": {
    "api_key_purchase": "https://api.realtimeapi.ai/purchase/cryptodata",
    "docs": "https://realtimeapi.ai/feeds/cryptodata"
  }
}

Every response carries X-RTAPI-Price, X-RTAPI-Cache (HIT with X-RTAPI-Cache-Layer and X-RTAPI-Data-Age, the age of our copy in seconds, or MISS), Server-Timing per phase and X-RTAPI-Gateway-Ms. Key calls add X-RTAPI-Remaining and X-RateLimit-* (exact when X-RTAPI-Quota-Source: do, approximate by a few calls when memo); paid responses carry PAYMENT-RESPONSE (settlement receipt).

Pay-per-time keys

For agents that run all day: one 402 round-trip buys a time pass scoped to one feed (1 hour, 7 days or 30 days). Paying again with the same key or wallet extends it from the current expiry.

TypeScript
// One 402 round-trip buys a feed-scoped key (returned once)
const res = await pay("https://api.realtimeapi.ai/purchase/cryptodata/monthly", { method: "POST" });
const { api_key, expires_at } = await res.json();
Use the key
curl "https://api.realtimeapi.ai/v1/cryptodata/market-health" -H "X-API-Key: $RTAPI_KEY"

Free key

1,000 calls a month across every feed. Get one from the API, or sign in and create it in the dashboard.

curl
curl -X POST https://api.realtimeapi.ai/keys/free -H "content-type: application/json" -d '{"email":"you@example.com"}'

Connect over MCP

The platform server at https://mcp.realtimeapi.ai/mcp (streamable HTTP) exposes discover, list_feeds, get_quote, call_feed and create_free_key; only call_feed needs a key or an x402 payment. Each feed also has a paid server at https://mcp.realtimeapi.ai/mcp/{feed}.

Claude Code
claude mcp add --transport http realtimeapi https://mcp.realtimeapi.ai/mcp
Claude Desktop (claude_desktop_config.json, via mcp-remote)
{
  "mcpServers": {
    "realtimeapi": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://mcp.realtimeapi.ai/mcp"
      ]
    }
  }
}
Cursor (~/.cursor/mcp.json)
{
  "mcpServers": {
    "realtimeapi": {
      "url": "https://mcp.realtimeapi.ai/mcp"
    }
  }
}

More clients (Codex, VS Code, Hermes) and a one-paste setup prompt that also adds the skill and a free key: AI quickstart.

Discover and quote

Semantic search (at most 5 results)
curl "https://api.realtimeapi.ai/discover?q=bitcoin+funding+rates&max_price=0.02"
Price check without paying
curl "https://api.realtimeapi.ai/quote?url=https%3A%2F%2Fapi.realtimeapi.ai%2Fv1%2Fcryptodata%2Fmarket-health"

OpenAPI documents

Each feed publishes an OpenAPI 3.1 document generated from the catalog. Every operation carries x-price.

Machine-readable catalog: llms.txt and llms-full.txt.

What gets billed

  • Only 2xx responses. A non-2xx from the provider is passed through, never charged and never settled.
  • A feed marked down by quality probes returns 503 with Retry-After and no charge.
  • Replaying a payment returns 409.
  • Keys hitting their quota get 429 with X-RateLimit-* headers.

Get a free key

1,000 calls a month across every feed. Who is setting it up?

No key needed at all: agents can pay per call in USDC with x402.