Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sportsxapp.com/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks through the shortest path from zero to a working GraphQL call against SportsX staging.
Use staging for anything you’re building. env="production" trades with real balances — don’t point a new integration at it until you’ve exercised the code path on staging.

Prerequisites

Walkthrough

1

Install the SDK

pip install \
  --index-url https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ \
  "stx-python>=0.5.0a1"
stx-python is in alpha on TestPyPI. Once stable it’ll be pip install stx-python from main PyPI. See Installation for the full story.Verify:
python -c "import stx; print('OK')"
2

Set credentials

The SDK reads credentials from three places, in this precedence: keyword arguments → environment variables → ~/.stx/credentials profile.For a first run, env vars are fastest:
export STX_EMAIL="you@example.com"
export STX_PASSWORD="your-password"
For long-lived setups, see Configuration → Profile files.
3

Make your first call

Create hello_stx.py:
hello_stx.py
from stx import STX, Selection

client = STX(region="ontario", env="staging")

markets = client.markets(
    selections=Selection("market_id", "status", "title"),
)

print(f"Got {len(markets)} markets")
for m in markets[:5]:
    print(f"  {m.market_id}  {m.status:<10}  {m.title}")
Run it:
python hello_stx.py
You should see something like:
Got 217 markets
  mkt_8f3...  open        Who wins Game 4 of the NBA Finals?
  mkt_4a2...  closed      NHL — Leafs vs Rangers, Mar 12
  ...
4

Place a resting order (and cancel it)

Orders are authenticated the same way; no extra setup. The example below places a deliberately-low LIMIT BUY at 1¢ — it sits in the orderbook without filling, so you can exercise the API without risking real positions.
from stx import STX, Selection

client = STX(region="ontario", env="staging")
client.login(params={})

# Find a tradable market.
markets = client.markets(
    params={"input": {"status": "OPEN", "trading": "TRUE", "limit": 5}},
    selections=Selection("market_id", "title"),
)
market_id = markets[0].market_id

# Place a resting LIMIT BUY at 1¢ — won't fill at that price.
result = client.place_order(
    params={
        "user_order": {
            "market_id": market_id,
            "order_type": "LIMIT",
            "action": "BUY",
            "price": 1,
            "quantity": 1,
        }
    },
    selections=Selection(order=Selection("id", "status")),
)
print(f"Placed: {result.order.id}  status={result.order.status}")

# Clean up.
client.cancel_order(params={"order_id": result.order.id})
See Trading for batch ops, odds-orders, and the rest of the surface.
5

Subscribe to a live feed (optional)

STXWebSocket is async-native. Save as feed.py:
feed.py
import asyncio
from stx import STX, STXWebSocket
from stx.enums import Channels

async def main():
    # The WS client re-uses the JWT cached by a prior STX login.
    STX(region="ontario", env="staging")  # seeds the auth singleton

    async def on_msg(msg):
        print(f"{msg.event}: {msg.payload}")

    async with STXWebSocket(region="ontario", env="staging") as ws:
        await ws.join(Channels.MARKETS, on_message=on_msg)
        await asyncio.sleep(30)   # listen for 30 seconds

asyncio.run(main())
Run it — you’ll see phx_reply (the join ack) followed by live market updates.

What you just did

  • Installed stx-python from PyPI.
  • Logged in with email/password — the SDK cached a JWT and will auto-refresh it at minute 59 of each 60-minute window.
  • Ran a GraphQL query with a narrowed field Selection (small payload).
  • Previewed an order without hitting the order book.
  • (Optionally) joined a Phoenix channel for live market updates.

Next steps

Authentication

2FA, long-lived profiles, and how tokens are refreshed.

Market data

Query orderbooks, event metadata, and historical data.

Trading

Place, cancel, and amend orders; fetch positions and fills.

WebSockets

Subscribe to the full catalog of Phoenix channels.