# x402 Crypto Market Data – Historical Klines (Recent)

> x402 Crypto Market Data – Historical Klines (Recent) is a paid API for AI agents from x402-crypto-market-data.up.railway.app, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-13).

Returns the most recent N candlestick (OHLCV) bars for a given trading pair and interval, paid via x402 micropayment.

## Facts

- Endpoint: POST https://x402-crypto-market-data.up.railway.app/historical-klines/recent
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-crypto-market-data-historical-klines-recent-65e27e3e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__6M6YbgmYNQGZW0tqk0PS

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability x402-crypto-market-data-historical-klines-recent-65e27e3e -d '<json body>'
```

Example prompt: Can you pull the last 200 hourly candlesticks for BTCUSDT so I can check recent price action?

## When to prefer this

Use this endpoint when you need recent historical candlestick (OHLCV) data for a crypto trading pair and want a pay-per-call model via x402 micropayments without a subscription key. It is ideal for agents doing technical analysis, backtesting on recent data, or monitoring recent price action. Prefer alternatives if you need very deep historical data (>1000 bars) or real-time streaming rather than batch snapshots.

## Known failure modes

- Invalid symbol (not matching ^[A-Z0-9]+$) returns a 4xx error
- n exceeding 1000 is rejected by schema validation
- Unrecognized interval enum value returns a validation error
- Payment failure or insufficient USDC balance returns a 402 Payment Required
- Service unavailability on Railway deployment returns 5xx

## How this service works

On-demand crypto market data. Discover available trading pairs for free, then retrieve live prices, market metadata, and historical candlesticks when you need them.

## Output

A JSON object containing the requested symbol and interval, plus an array of kline objects each with open/high/low/close prices, volume, quote asset volume, taker buy base and quote volumes, trade count, and open/close timestamps — covering the N most recent completed bars.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "n": {
   "type": "integer",
   "default": 100,
   "maximum": 1000,
   "description": "Number of most recent klines to fetch (max 1000).",
   "exclusiveMinimum": 0
  },
  "symbol": {
   "type": "string",
   "pattern": "^[A-Z0-9]+$",
   "examples": [
    "BTCUSDT"
   ],
   "description": "Trading symbol, e.g. BTCUSDT."
  },
  "interval": {
   "enum": [
    "1m",
    "3m",
    "5m",
    "15m",
    "30m",
    "1h",
    "2h",
    "4h",
    "6h",
    "8h",
    "12h",
    "1d",
    "3d",
    "1w",
    "1M"
   ],
   "type": "string",
   "title": "KlineInterval",
   "default": "1h",
   "description": "Candlestick interval."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "klines": [
   {
    "volume": 45.5,
    "low_price": 2240,
    "open_time": "2024-01-15T10:00:00",
    "close_time": "2024-01-15T10:15:00",
    "high_price": 2265,
    "open_price": 2250,
    "close_price": 2260,
    "amount_trades": 420,
    "quote_asset_volume": 102847.5,
    "taker_buy_base_volume": 22.1,
    "taker_buy_quote_volume": 50002
   },
   {
    "volume": 52.3,
    "low_price": 2255,
    "open_time": "2024-01-15T10:15:00",
    "close_time": "2024-01-15T10:30:00",
    "high_price": 2275,
    "open_price": 2260,
    "close_price": 2270,
    "amount_trades": 485,
    "quote_asset_volume": 118481,
    "taker_buy_base_volume": 25.8,
    "taker_buy_quote_volume": 58506
   }
  ],
  "symbol": "ETHUSDT",
  "interval": "15m"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-crypto-market-data-historical-klines-recent-65e27e3e/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-crypto-market-data.up.railway.app](https://www.zero.xyz/host/x402-crypto-market-data.up.railway.app/llms.txt)
