stx-python
The official Python SDK for the STX exchange.
pip install stx-python
Python 3.9 or newer.
Quickstart
You need an API key for the STX exchange you are building against. Environments lists the exchanges and where to get a key, and Authentication shows how to give it to the SDK.
from stx import STX
# Reads your API key and exchange from STX_* environment variables or ~/.stx/credentials.
with STX() as client:
# status "open": markets that have opened for trading (not scheduled, closed or settled).
# trading=True: only markets accepting orders right now (an open market can be paused).
# limit: markets per page. Looping over page gives this page; client.iter_markets() walks every page.
page = client.markets(status="open", trading=True, limit=5)
for market in page:
# bids are what buyers will pay, offers what sellers will accept, best price first.
# Prices are dollars per contract, as strings; a winning contract pays market.max_price.
bid = market.bids[0].price if market.bids else "-" # "-" when nobody is bidding
offer = market.offers[0].price if market.offers else "-"
print(f"{market.event_title}: {market.title} bid {bid} offer {offer}")
Sample output:
New York Yankees at San Diego Padres: Padres First Run bid - offer -
New York Yankees at San Diego Padres: Yankees First Run bid 0.4200 offer -
Norfolk State Spartans at Old Dominion Monarchs: Old Dominion Score Last bid - offer -
Norfolk State Spartans at Old Dominion Monarchs: Norfolk St Score Last bid - offer -
Tampa Bay Rays at Philadelphia Phillies: MLB TB @ PHI bid - offer -
A bid of 0.4200 on a market whose winning contract pays 1.0000 means a buyer will pay 42 cents for a contract that pays $1 if the Yankees score first.
One market from the response (selected fields)
{
"market_id": "ddb216af-e752-422c-8688-52f95630b219",
"symbol": "STXMLB-26SEP042140NYYSD-ESLAWAYFIRSTRUNNA",
"event_title": "New York Yankees at San Diego Padres",
"title": "Yankees First Run",
"question": "Will New York Yankees score the first run of the game?",
"status": "open",
"trading": true,
"event_start": "2026-09-05T01:40:00.000000Z",
"max_price": "1.0000",
"last_traded_price": null,
"bids": [
{ "price": "0.4200", "quantity": "5.00" },
{ "price": "0.2400", "quantity": "4.00" },
{ "price": "0.2300", "quantity": "2.00" }
],
"offers": []
}
Every market is a stx.models.Market; market.model_dump() gives you the dict. Every field is described in the API reference.
For asyncio, AsyncSTX has the same methods to await, and client.websocket() streams the order book, trades and your own orders, fills and balance.
Documentation
MIT license. Use of the STX API and exchange is subject to the STX terms of use and privacy policy: United States (terms of use, privacy policy), Ontario (terms of use, privacy policy).
Metadata
Release files for stx-python 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stx_python-0.6.0.tar.gz | 54.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stx_python-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 110.3 kB
Release files / stx_python-0.6.0.tar.gz
| Download URL | stx_python-0.6.0.tar.gz |
|---|---|
| Size | 54.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25f8e58617691f28c29236e28ca47635468f59f10dbf1e2be8f9b6fffa307b9e
|
|
BLAKE2b-256 checksum How to use checksums |
8ed4f282b427336b9c961e4887b14b2f4fd34db15d51fc7aa422dc5d7cc4333f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / stx_python-0.6.0-py3-none-any.whl
| Download URL | stx_python-0.6.0-py3-none-any.whl |
|---|---|
| Size | 56.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e887801bb04442ddf2f334860c45fcb1fbf8b9f24c77d3bcfc78391a58af4da
|
|
BLAKE2b-256 checksum How to use checksums |
12f4f8b9aab5e06618b417753b1068f6e6f51dad77adc1c33f5a47c338b5cde9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|