Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stx-python 0.6.0rc1
File Size Uploaded
stx_python-0.6.0rc1.tar.gz 54.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stx-python 0.6.0rc1
File Interpreter ABI Platform
stx_python-0.6.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 110.4 kB

Release files / stx_python-0.6.0rc1.tar.gz

Download URL stx_python-0.6.0rc1.tar.gz
Size 54.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7aaabf12b9ca1c2b388039ca220055996e5871e7ccc3b90015df376080e52446
BLAKE2b-256 checksum
How to use checksums
c738d06f7a0cb8e088e33953a0507d63f4bcb60b446ec154fd901353c3294293
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.0rc1-py3-none-any.whl

Download URL stx_python-0.6.0rc1-py3-none-any.whl
Size 56.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68c5de171061a00e78b2436ac111a9297e57f79dfbdf77de9f6bd90e726967df
BLAKE2b-256 checksum
How to use checksums
28c778438aa8592677270bbeff6bf81dcff23022869e4c2ab7424c01292c7f59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.6.0

2 release files

This release

0.6.0rc1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page