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.7.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 | Provenance | Actions |
|---|---|---|---|---|
| stx_python-0.7.0.tar.gz | 60.6 kB | Without provenance | Details for stx_python-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stx_python-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for stx_python-0.7.0-py3-none-any.whl |
Total release size: 123.7 kB
Release files / stx_python-0.7.0.tar.gz
| Download URL | stx_python-0.7.0.tar.gz |
|---|---|
| Size | 60.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36b369a72d11127bd7a2200625e6b90e34ff506f323f317c66e3114b48f3fa02
|
|
BLAKE2b-256 checksum How to use checksums |
07a150871f6b118428c97788ccd1a013a5a192c74f22292f8f31feddac1f8171
|
| 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.7.0-py3-none-any.whl
| Download URL | stx_python-0.7.0-py3-none-any.whl |
|---|---|
| Size | 63.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f325e2e16eab40c904e569cff18c42df7afe8de038bee16213df9002ebdae8b
|
|
BLAKE2b-256 checksum How to use checksums |
aa533f42fe90b2b078130e0d621b370b8e48273409a81a45c4ab89fa56876d9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for stx-python 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.