# Crypto trading bot data API

> Feed a crypto trading bot funding rates, open interest, liquidations, order books, options and candles from one REST and WebSocket API with one key.

Source: https://www.f1ow.com/docs/use-cases/trading-bots

A bot needs clean inputs from many places: candles from one venue, funding from another, liquidations from a third, options from somewhere else. Each has its own keys, limits and formats. f1ow gives you all of them behind **one REST API and one WebSocket**, with one key and consistent JSON.

## Building blocks for strategies

| Signal | Tool | REST |
| --- | --- | --- |
| OHLCV, spot or perp | [Candles](https://www.f1ow.com/docs/tools/market_candles) | `GET /v1/market/candles/{symbol}` |
| Months of paged history (price, OI, funding, liquidations) | [Bulk History](https://www.f1ow.com/docs/tools/market_history) | `GET /v1/market/history/{symbol}` |
| Funding, with a 1-year percentile | [Funding](https://www.f1ow.com/docs/tools/funding_current) | `GET /v1/derivatives/funding/{symbol}` |
| Open interest and its baseline | [Open Interest](https://www.f1ow.com/docs/tools/derivatives_open_interest) | `GET /v1/derivatives/open-interest/{symbol}` |
| OI × taker flow: new longs vs short covering | [Perp Flow](https://www.f1ow.com/docs/tools/derivatives_flow) | `GET /v1/derivatives/flow/{symbol}` |
| Liquidation history and cascades | [Liquidation History](https://www.f1ow.com/docs/tools/derivatives_liquidations) | `GET /v1/derivatives/liquidations/{symbol}` |
| Order-book depth, imbalance and fill cost | [Order Book](https://www.f1ow.com/docs/tools/flow_orderbook) | `GET /v1/flow/orderbook/{symbol}` |
| Evidence-graded price levels | [Perp Price Levels](https://www.f1ow.com/docs/tools/flow_levels) | `GET /v1/flow/levels/{symbol}` |
| Indicators across timeframes | [Technicals](https://www.f1ow.com/docs/tools/ta_technicals) | `GET /v1/technicals/{symbol}` |
| Options IV, skew and odds | [Implied Volatility](https://www.f1ow.com/docs/tools/options_volatility), [Options-Implied Odds](https://www.f1ow.com/docs/tools/options_probability) | `GET /v1/options/...` |

Every tool page has the full parameter list, the request in cURL, TypeScript and Python, and a real response.

## Backtest, then go live

Pull history with `market_history`, which takes up to 1,000 rows per call. Pass `nextEndMs` back as `end` to page backwards. Funding and OI history go back years at daily resolution:

```python
import os, requests

H = {"Authorization": f"Bearer {os.environ['F1OW_API_KEY']}"}
rows, end = [], None
while len(rows) < 3000:
    params = {"metric": "funding", "interval": "1d", "limit": 1000, **({"end": end} if end else {})}
    page = requests.get("https://mcp.f1ow.com/v1/market/history/BTC", headers=H, params=params).json()
    rows = page["rows"] + rows  # each page is oldest-first; earlier pages come next
    end = page.get("nextEndMs")
    if not end:
        break
```

The field names in the response are documented on the tool page and typed in the [OpenAPI spec](https://mcp.f1ow.com/openapi.json).

## Push instead of poll

Polling every symbol every minute wastes calls. [Subscribe over WebSocket](https://www.f1ow.com/docs/api/websocket) instead. The server re-runs the tool and pushes only when the result changes, and only pushes are metered.

```json
{ "jsonrpc": "2.0", "id": 1, "method": "subscriptions/subscribe",
  "params": { "name": "derivatives_open_interest", "arguments": { "symbol": "BTC" }, "intervalSeconds": 60 } }
```

## Read-only by design

f1ow never trades. Your bot keeps its own exchange keys and order logic; f1ow is the market-data and research layer. Snapshots carry `generatedAt` and coverage notes, so check freshness before acting.

> Get a key for your bot: https://www.f1ow.com/dashboard
