SQL access over HTTPS
Send SELECT queries through a REST endpoint and receive structured JSON for analytics, reporting, and research apps. No bulk CSV dumps to host yourself.
Preparing your API workspace…
Historical options data API over REST with ClickHouse SQL. Query U.S. option trades for backtests and research without bulk file downloads. Paid Pro covers the past 15 days of trades, with a 15-minute delay.
POST https://www.optiondata.io/api/historical/sqlCopy this prompt, paste it into ChatGPT, Claude, Claude Code, Cursor, or Codex, then add your question. It tells the model to read our public docs first — no API key needed for that step.
You are helping me use OptionData (https://www.optiondata.io/), an OPRA-licensed U.S. equity options data API.
Before answering, fetch these public files (no login required) and treat them as the source of truth:
- https://www.optiondata.io/llms.txt — short product map (same content as https://www.optiondata.io/llm.txt)
- https://www.optiondata.io/llms-full.txt — full API reference
- https://www.optiondata.io/openapi.json — HTTP OpenAPI
Do not invent endpoints, fields, tables, or limits. Prefer `Authorization: Bearer apikey_…` for HTTP APIs. Realtime uses `wss://ws.optiondata.io` with a `token` query parameter.
Products:
- Realtime trades WebSocket: wss://ws.optiondata.io
- Historical SQL: POST https://www.optiondata.io/api/historical/sql
- Option chain: POST https://www.optiondata.io/api/option-chain
- Market structure: GET https://www.optiondata.io/api/v1/market-structure/{symbol}
I am asking about: Historical Option Trades API (SQL)
- Product / playground page: https://www.optiondata.io/historical_data
- Markdown: https://www.optiondata.io/md/historical-option-trades-api
- HTML docs: https://www.optiondata.io/docs/historical-option-trades-api
My question:
Send SELECT queries through a REST endpoint and receive structured JSON for analytics, reporting, and research apps. No bulk CSV dumps to host yourself.
Run SELECT queries over unmodified RAW trade history (not AGGREGATED). Stored columns and derived-field formulas are in the historical SQL docs.
SELECT-only checks, table allowlists, row caps, and ClickHouse limits protect the shared warehouse while you run custom research SQL.
Historical option trades SQL reference
Paid Pro includes the past 15 days of trades, with a 15-minute delay. Full-archive access is not included. Trial access is unchanged.
It means 360 elapsed hours from query execution, including weekends and holidays. The oldest timestamp is included; the newest 15 minutes are excluded.
Check your symbol and date filters. Paid queries exclude trades older than 15 days and newer than 15 minutes. A range crossing the boundary includes only eligible trades, including in aggregates. See the Historical SQL reference for details.
Yes. POST guarded ClickHouse SELECT queries to /api/historical/sql with your API key and receive JSON rows. Paid access covers the past 15 days with a 15-minute delay.
Yes. Stored trade rows include IV and Greeks when available. Some metrics such as premium are derived in SQL — see the historical SQL docs for stored vs derived columns.
No. The historical API is request-based. You query the warehouse directly instead of downloading and maintaining static files.
Historical SQL stores original OPRA-derived trade prints without AGGREGATED consolidation. Build your own GROUP BY aggregations in SQL when you need them.
POST a form or JSON body with api_key and a SELECT-only SQL string to https://www.optiondata.io/api/historical/sql. The warehouse is ClickHouse; responses are JSON rows plus meta/statistics when available.
Query RawOptionTrades (and allowed materialized views). Partition on date and filter symbol early. Stored vs derived columns are documented in the historical SQL reference — this page does not restate the schema.
Guardrails enforce SELECT-only, no multi-statements/comments, table allowlists, and row/time caps. Trial accounts receive smaller row caps; paid subscribers can query the past 15 days under the same Pro plan.
Historical option trades SQL reference → · All API docs · openapi.json
curl -X POST 'https://www.optiondata.io/api/historical/sql' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "YOUR_API_KEY",
"sql": "SELECT symbol, strike, put_call, size, price, toFloat64(price) * size * 100 AS premium FROM RawOptionTrades WHERE date = (SELECT max(date) FROM RawOptionTrades WHERE symbol = '\''AAPL'\'' AND date >= today() - 7) AND symbol = '\''AAPL'\'' ORDER BY premium DESC LIMIT 25"
}'Field names, types, filters, limits, and error codes live in the public API reference. This product page does not keep a second copy of the schema.