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.
Get 50% off on all plans for the first year – contact sales for a promotional code.
Historical options data API over REST with ClickHouse SQL. Query U.S. option trades for backtests and research without bulk file downloads. History starts 2025-02-18 with 2.8B+ stored prints in RawOptionTrades.
Copy 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.
Yes. POST guarded ClickHouse SELECT queries to /api/historical/sql with your API key and receive JSON rows. Trade history starts 2025-02-18 in RawOptionTrades.
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; active realtime subscribers get full historical access 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) 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.