Markets¶
Operate on Kalshi markets — the leaf-level YES/NO contracts. List, fetch a single market, pull its orderbook, get candlesticks (single or bulk), list recent trades.
Quick reference¶
| Method | Endpoint | Auth |
|---|---|---|
list(...) |
GET /markets |
no |
list_all(...) |
walks list |
no |
get(ticker) |
GET /markets/{ticker} |
no |
orderbook(ticker, depth=None) |
GET /markets/{ticker}/orderbook |
yes |
candlesticks(series_ticker, ticker, *, start_ts, end_ts, period_interval, ...) |
GET /series/{series_ticker}/markets/{ticker}/candlesticks |
no |
bulk_candlesticks(*, market_tickers, ...) |
GET /markets/candlesticks |
no |
bulk_orderbooks(*, tickers) |
GET /markets/orderbooks |
yes |
list_trades(...) |
GET /markets/trades |
no |
list_trades_all(...) |
walks list_trades |
no |
Orderbook endpoints require auth
orderbook() and bulk_orderbooks() raise AuthRequiredError on an
unauthenticated client. The rest of the market-data surface is public.
List markets¶
page = client.markets.list(
status="open", # MarketStatusLiteral
series_ticker="KXPRES",
event_ticker="KXPRES-24",
tickers=["KXPRES-24-DJT", "KXPRES-24-KH"], # or "KXPRES-24-DJT,KXPRES-24-KH"
min_close_ts=1_700_000_000,
max_close_ts=1_800_000_000,
mve_filter="exclude", # MveFilterLiteral
limit=200,
)
for market in page:
print(market.ticker, market.yes_bid, market.yes_ask)
tickers accepts a list[str] or a comma-joined string — the SDK comma-joins
for the wire (this endpoint uses comma-join form, not the explode form
used by bulk_orderbooks).
All the *_ts filters (min_close_ts, max_close_ts, min_open_ts,
max_open_ts, min_settle_ts, max_settle_ts, min_volume_24h,
min_total_volume, min_total_open_interest) are Unix-second ints. Pair them
with min_open_ts/max_open_ts etc. as needed.
list_all(...) walks cursors and returns an iterator — see
Pagination.
Get one market¶
market = client.markets.get("KXPRES-24-DJT")
print(market.status, market.yes_bid, market.yes_ask, market.volume)
Orderbook (single)¶
ob = client.markets.orderbook("KXPRES-24-DJT", depth=20)
print(ob.yes[:5]) # list[OrderbookLevel], best-first
print(ob.no[:5])
depth is the number of price levels per side (default unbounded). Wire keys
orderbook_fp.yes_dollars / no_dollars are normalized to ob.yes / ob.no
of type Decimal.
Bulk orderbooks¶
books = client.markets.bulk_orderbooks(tickers=["KXPRES-24-DJT", "KXPRES-24-KH"])
for ob in books:
print(ob.market_ticker, ob.yes[0])
- Cap: 100 tickers per call.
- Wire format: explode (
?tickers=a&tickers=b). The SDK builds this for you regardless of whether you passlist[str]or a comma-joined string. - Auth required.
Candlesticks¶
candles = client.markets.candlesticks(
series_ticker="KXPRES",
ticker="KXPRES-24-DJT",
start_ts=1_700_000_000,
end_ts=1_700_100_000,
period_interval=60, # seconds: 60, 3600, 86400
include_latest_before_start=True,
)
for c in candles.candlesticks:
print(c.end_period_ts, c.yes_bid)
include_latest_before_start includes the most recent candle before
start_ts for seamless rendering.
Bulk candlesticks¶
batches = client.markets.bulk_candlesticks(
market_tickers=["KXPRES-24-DJT", "KXPRES-24-KH"], # 1–100 tickers
series_ticker="KXPRES", # optional shard hint
start_ts=1_700_000_000,
end_ts=1_700_100_000,
period_interval=3600,
)
for batch in batches: # list[MarketCandlesticks]
print(batch.market_ticker, len(batch.candlesticks))
Comma-joined wire form (?market_tickers=a,b,c). 100-ticker cap.
List trades¶
page = client.markets.list_trades(
ticker="KXPRES-24-DJT",
min_ts=1_700_000_000,
max_ts=1_700_100_000,
limit=200,
)
for trade in page:
print(trade.trade_id, trade.taker_side, trade.yes_price, trade.count)
Reference¶
kalshi.resources.markets.MarketsResource ¶
Bases: SyncResource
Sync markets API.
bulk_candlesticks ¶
bulk_candlesticks(
*,
market_tickers: list[str] | str,
start_ts: int,
end_ts: int,
period_interval: int,
include_latest_before_start: bool | None = None
) -> builtins.list[MarketCandlesticks]
Fetch candlesticks for up to 100 markets in a single call.
market_tickers serializes as a comma-separated string per spec
(not exploded). Accepts a list, tuple, or pre-joined string.
Spec requires at least one ticker (max 100).
bulk_orderbooks ¶
Fetch orderbooks for up to 100 tickers in a single call.
Spec requires auth and at least one ticker (max 100). tickers
wire format is ?tickers=a&tickers=b (spec style: form,
explode: true) — httpx serializes list values that way by default.
kalshi.resources.markets.AsyncMarketsResource ¶
Bases: AsyncResource
Async markets API.
list_all ¶
list_all(
*,
status: MarketStatusLiteral | None = None,
series_ticker: str | None = None,
event_ticker: str | None = None,
tickers: list[str] | str | None = None,
mve_filter: MveFilterLiteral | None = None,
min_created_ts: int | None = None,
max_created_ts: int | None = None,
min_updated_ts: int | None = None,
min_close_ts: int | None = None,
max_close_ts: int | None = None,
min_settled_ts: int | None = None,
max_settled_ts: int | None = None,
limit: int | None = None,
max_pages: int | None = None
) -> AsyncIterator[Market]
Non-async method that returns an async iterator for direct use with async for.
list_trades_all ¶
list_trades_all(
*,
ticker: str | None = None,
min_ts: int | None = None,
max_ts: int | None = None,
limit: int | None = None,
max_pages: int | None = None
) -> AsyncIterator[Trade]
Returns an async iterator — use async for.
bulk_candlesticks
async
¶
bulk_candlesticks(
*,
market_tickers: list[str] | str,
start_ts: int,
end_ts: int,
period_interval: int,
include_latest_before_start: bool | None = None
) -> builtins.list[MarketCandlesticks]
Fetch candlesticks for up to 100 markets in a single call.
market_tickers serializes as a comma-separated string per spec
(not exploded). Accepts a list, tuple, or pre-joined string.
Spec requires at least one ticker (max 100).
bulk_orderbooks
async
¶
Fetch orderbooks for up to 100 tickers in a single call.
Spec requires auth and at least one ticker (max 100). tickers
wire format is ?tickers=a&tickers=b (spec style: form,
explode: true) — httpx serializes list values that way by default.