> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.immix.xyz/sdk/python/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.immix.xyz/_mcp/server. # Python SDK The Python SDK covers the REST API and the market-data WebSocket. Its core is generated from the same contracts this portal documents, so it follows them release by release. A small hand-written layer adds what a generator cannot: a market-data stream that authenticates and reconnects by itself, and helpers for money and idempotency keys. > **Note** > > The SDK is in **private preview**. Access is granted per organisation during onboarding, and you > receive each release as a Python wheel. It is not on a public package index yet. ## Install The SDK needs Python 3.10 or newer. Install the wheel you were given: ```bash pip install immix--py3-none-any.whl ``` The package imports as `immix`. ## The REST API There is no public REST environment yet, so pass the base URL your onboarding gave you: ```python from immix import Immix client = Immix(base_url="https://", token=token) me = client.users.get_me() print(me.org_name, [c.value for c in me.capabilities]) ``` Every write takes an idempotency key: `immix.new_idempotency_key()` mints one. Keep it, and send the same key when you retry that write. Money is a decimal string, and `immix.to_decimal` and `immix.format_decimal` cross to and from `Decimal` exactly — never through a float. ## Market data ```python import asyncio from immix import MarketData, Reconnected from immix.market_data import TradeEvent async def main() -> None: async with MarketData(token=token) as md: await md.subscribe("trade.OKX@BTC/USDT") async for frame in md: if isinstance(frame, Reconnected): print("reconnected: frames sent meanwhile were not seen") elif isinstance(frame, TradeEvent): for fill in frame.data: print(frame.topic, fill.side.value, fill.qty, "@", fill.px) asyncio.run(main()) ``` `MarketData` opens the production socket. It sends your token as a message once the socket is open, never in the handshake. When the connection drops, it reconnects, authenticates again and resubscribes every topic it held, then yields `Reconnected` where the gap is. Every frame is a typed model of the [Market Data WebSocket reference](/api-reference/market-data/overview). A refused token raises `immix.AuthenticationError`, and a subscription refused as a whole raises `immix.SubscriptionError`. > Private preview — both APIs from Python