CuteMarkets Python SDK for Real-Time and Historical Options Data
The official Python options API client for CuteMarkets. Use it to query real-time and historical options data from Python, including options chain API snapshots, historical contracts with as_of, quotes, trades, aggregates, expirations, and ticker search.
cutemarkets wraps the CuteMarkets v1 REST API in a typed, namespaced, Pythonic interface. Sync and async clients share the same method surface, response models are pydantic v2 classes that preserve the raw payload on .raw, every list endpoint ships with both one-page and auto-paginating variants, and every error path maps to a specific exception class so you can handle plan gating, rate limiting, and missing resources cleanly.
Quick links:
Table of contents
- Use Cases
- Explore Examples
- Features
- Why this SDK instead of raw HTTP requests
- Installation
- Quick start
- Authentication
- Client options
- Resource reference
- Models
- Pagination
- Filters and range queries
- Dates, enums, booleans
- Errors
- Rate limits
- Async usage
- Recipes
- Testing your integration
- Versioning and compatibility
- Development
- License
Use Cases
- Build an options chain scanner for liquid contracts and spread filters.
- Reconstruct historical contracts with
as_of for backtests and event studies.
- Estimate implied move around earnings from the ATM straddle.
- Inspect quote quality before you trust an options backtest.
Explore Examples
Features
- Sync (
CuteMarkets) and async (AsyncCuteMarkets) clients with identical surfaces.
- Namespaced methods that mirror the docs:
client.options.chain(...), client.options.aggs.range(...), client.options.indicators.sma(...), client.tickers.search(...), ...
- Typed
pydantic v2 models for every response, with .raw preserving the original JSON so new server fields never block you.
- Short-name preservation on abbreviated wire payloads (
LastTrade.T/p/s/..., Aggregate.o/h/l/c/v/vw/t/n) plus readable property aliases (.ticker, .price, .open, .close, ...).
- One-shot
list(...) returns a Page[T] (results, next_url, request_id, rate_limit, .next()). Auto-paginating iter_list(...) / iter_*(...) generators walk every page for you.
- Automatic date / datetime / bool / Enum coercion and underscore-to-dot rewriting for range filters (
strike_price_gte=100 → strike_price.gte=100).
- Typed exception hierarchy (
AuthenticationError, ForbiddenError, LookbackExceededError, NotFoundError, RateLimitError, ...) selected from the error.code envelope field.
- Rate-limit header introspection via
page.rate_limit, client.last_rate_limit, and client.last_request_id.
- Opt-in exponential-backoff retries on 429, 5xx, and transient network errors.
- Custom
httpx.Client / httpx.AsyncClient / httpx.BaseTransport injection for testing.
Why this SDK instead of raw HTTP requests
Raw HTTP calls work for quick experiments, but they force you to rebuild the same glue in every project: authentication headers, pagination, date coercion, query serialization, response typing, and error mapping. This SDK centralizes that work so your research code can focus on chain selection, contract filtering, quote quality, and analytics rather than transport plumbing.
That matters even more for historical options data. Workflows like contract reconstruction with as_of, quote-aware filtering, and earnings event studies are easier to maintain when the API surface is typed, consistent, and reusable across both sync and async code.
Installation
pip install cutemarkets
Requires Python 3.9 or newer. The only runtime dependencies are httpx and pydantic.
Development extras:
pip install "cutemarkets[dev]"
Quick start
from cutemarkets import CuteMarkets
client = CuteMarkets(api_key="cm_...")
chain = client.options.chain("NFLX", limit=5)
for contract in chain:
print(contract.details.ticker, contract.break_even_price, contract.greeks.delta if contract.greeks else None)
print("request id:", chain.request_id)
print("remaining this minute:", chain.rate_limit.remaining_minute)
Async equivalent:
import asyncio
from cutemarkets import AsyncCuteMarkets
async def main():
async with AsyncCuteMarkets(api_key="cm_...") as client:
chain = await client.options.chain("NFLX", limit=5)
for contract in chain:
print(contract.details.ticker)
asyncio.run(main())
Authentication
API keys are prefixed cm_... and are passed as a Bearer token on the Authorization header.
Three ways to provide your key, evaluated in this order:
- Constructor argument:
client = CuteMarkets(api_key="cm_...")
CUTEMARKETS_API_KEY environment variable:export CUTEMARKETS_API_KEY=cm_xxxxxxxxxxxxxxxx
client = CuteMarkets() # auto-picks up the env var
- Runtime setter:
client.set_api_key("cm_...")
Get a free key at cutemarkets.com/signup. Every request's request_id is echoed back in responses and errors, so include it in support conversations.
Unauthenticated endpoint
client.status() hits /v1/status/ and does not require an API key. It works even before you configure credentials, so it's handy for readiness probes.
Client options
CuteMarkets(
api_key: str | None = None,
*,
base_url: str = "https://api.cutemarkets.com",
timeout: float = 30.0,
max_retries: int = 2,
headers: dict[str, str] | None = None,
transport: httpx.BaseTransport | None = None,
http_client: httpx.Client | None = None,
)
| Argument |
Purpose |
api_key |
Override or supply the API key. Overrides CUTEMARKETS_API_KEY. |
base_url |
Point the client at a different host (e.g. a staging or proxy URL). |
timeout |
Per-request timeout in seconds (applies to connect + read). |
max_retries |
Retry attempts on 429, 5xx, and transient network errors. 0 disables retries. |
headers |
Extra headers merged onto every request (useful for tracing or proxy auth). |
transport |
Pass an httpx.MockTransport (or any httpx.BaseTransport) for tests. |
http_client |
Bring your own httpx.Client when you want custom transport, event hooks, or connection pooling. |
AsyncCuteMarkets accepts the same kwargs, with transport: httpx.AsyncBaseTransport and http_client: httpx.AsyncClient.
Both classes support the context-manager protocol:
with CuteMarkets(api_key="cm_...") as client:
...
async with AsyncCuteMarkets(api_key="cm_...") as client:
...
Resource reference
Every method below links to the matching page under docs/. Every response is a pydantic model — dotted attribute access, .model_dump() for a dict, .raw for the untouched payload.
client.status()
Poll the public health endpoint. No API key required.
status = client.status()
status.status # "ok" or "degraded"
status.is_ok # bool
status.services["api"].status
status.services["database"].latency_ms
client.tickers.search(query=..., limit=...)
docs/ticker-search.md
for row in client.tickers.search(query="NFLX", limit=8):
print(row.symbol, row.name)
client.tickers.expirations(ticker)
docs/expirations.md
exp = client.tickers.expirations("NFLX")
exp.results # ["2026-04-02", "2026-04-10", ...]
client.options.chain(ticker, **filters)
docs/option-chain.md
Returns a Page[ContractSnapshot]. Accepts strike_price, expiration_date, contract_type, the range filters (strike_price_gte, expiration_date_lt, ...), sort, order, limit, and page.
chain = client.options.chain(
"NFLX",
contract_type="call",
strike_price_gte=90,
strike_price_lte=110,
sort="strike_price",
order="asc",
limit=50,
)
for c in chain:
print(c.details.ticker, c.break_even_price, c.implied_volatility)
client.options.iter_chain("NFLX", ...) auto-follows next_url.
client.options.snapshot(underlying, option_contract)
docs/option-contract-snapshot.md
snap = client.options.snapshot("NFLX", "O:NFLX260410C00060000")
snap.greeks.delta
snap.underlying_asset.price
client.options.contracts.list(**filters) / .get(options_ticker, as_of=None) / .iter_list(**filters)
docs/contracts.md
# Paged list
page = client.options.contracts.list(
underlying_ticker="NFLX",
expiration_date_gte="2026-04-01",
limit=1000,
)
# Walk every contract across pages
for c in client.options.contracts.iter_list(underlying_ticker="NFLX"):
print(c.ticker)
# Detail for one contract, optionally as-of a historical date
from datetime import date
detail = client.options.contracts.get("O:NFLX260402C00075000", as_of=date(2026, 1, 15))
client.options.trades.list(ticker, **filters) / .last(ticker) / .iter_list(...)
docs/trades.md
# Historical trades
page = client.options.trades.list(
"O:NFLX260402C00075000",
timestamp_gte="2026-03-01",
timestamp_lte="2026-03-31",
sort="timestamp",
order="desc",
limit=1000,
)
# Compact "last trade" shape (abbreviated keys + readable aliases)
last = client.options.trades.last("O:NFLX260410C00060000")
last.price # property alias for last.p
last.size # property alias for last.s
last.ticker # property alias for last.T
last.raw # the untouched {"T": ..., "p": ..., "s": ..., ...}
client.options.quotes.list(ticker, **filters) / .iter_list(...) — Expert Plan only
docs/quotes.md
Non-Expert keys receive HTTP 403, surfaced as ForbiddenError: