Skip to main content

Official Python client for the Synthetix V4 perpetual futures exchange — REST + WebSocket, EIP-712 signing built in

Project description

synthetix-sdk

The official Python client for the Synthetix V4 perpetual futures exchange. Provides REST and WebSocket access for market data, trading, and account management, with EIP-712 signing built in.

Full API docs: developers.synthetix.io.

Get going in 30 seconds with Claude Code

The fastest way to try the SDK is the bundled Claude Code skill. Clone the repo, run /synthetix in a Claude Code session, and Claude will set up the environment, write and run example scripts, and explain the SDK as you go — no reading docs first.

git clone https://github.com/Synthetixio/synthetix-sdk
cd synthetix-sdk

Then in Claude Code:

/synthetix stream live prices for ETH-USDT
/synthetix place a limit order
/synthetix check my open positions
/synthetix watch my positions in real time

Claude does the wiring — .venv setup, dependency install, script generation, running, and walking you through the output. Pass any natural-language goal after the slash command.

Installation

To use the SDK in your own project:

pip install synthetix-sdk

Three runtime dependencies: requests, eth-account, websockets. Python 3.10+.

Quick Start

from synthetix import Synthetix

# Public market data — no private key needed
snx = Synthetix()
markets = snx.get_markets()
for m in markets:
    print(m["symbol"], m["description"])

# Authenticated — required for trading and account queries
snx = Synthetix(private_key="0x...")
print(snx.get_positions())
print(snx.get_portfolio())

For WebSocket streaming and async trading:

import asyncio
from synthetix import Synthetix

async def main():
    snx = Synthetix(private_key="0x...")

    # Stream real-time prices (no auth required)
    sub = await snx.subscribe(
        "marketPrices",
        lambda d: print(d),
        symbol="ETH-USDT",
    )

    # Place an order over WebSocket
    result = await snx.ws_place_order(
        symbol="BTC-USDT",
        side="buy",
        amount="0.001",
        price="90000",
    )

    await asyncio.sleep(10)
    await snx.unsubscribe(sub)
    await snx.close()

asyncio.run(main())

Features

Market data (public, no key required)

  • List markets, fees, funding rates, open interest
  • Tickers, mark prices, mids
  • Order books at multiple depths
  • Recent trades, candles, funding rate history

Trading

  • Market, limit (GTC/GTD/IOC/post-only), TWAP, stop-loss, and take-profit orders
  • Modify and cancel orders (single, batch, by client order ID, or all)
  • Update leverage per market
  • Schedule deferred cancellations as a kill-switch

Account management

  • Positions, P&L, balance, portfolio, performance history
  • Trade and order history, open orders, fills
  • Funding payments and rate-limit status
  • Sub-accounts: create, query, transfer collateral
  • Delegated signers for ops accounts

WebSocket (async)

  • Live subscriptions: prices, orderbook (snapshot/diff/managed), trades, positions, orders, fills, balances
  • WS-native trading methods (ws_place_order, ws_cancel_order, ws_modify_order, …) — same signing, lower latency than REST
  • Auto-reconnect with auth re-handshake and subscription replay
  • Per-callback error handlers; sync and async callbacks both supported

Configuration

Synthetix(
    private_key=None,        # Omit for read-only mode
    subaccount_id=None,      # Auto-discovered if not set
    timeout=None,            # Request timeout in seconds
    expires_after_ms=60000,  # Signed-message expiry window
)

Examples

The repo includes standalone scripts for every endpoint under examples/rest/ and examples/ws/. Each is runnable on its own:

# Market data (no key)
python examples/rest/fetch-markets.py
python examples/rest/fetch-orderbook.py

# Trading (requires PRIVATE_KEY env var)
python examples/rest/create-limit-gtc-order.py
python examples/rest/cancel-order.py

# WebSocket
python examples/ws/async-watch-ticker.py
python examples/ws/async-market-order.py
python examples/ws/async-watch-positions.py

API reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synthetix_sdk-0.3.0.tar.gz (66.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synthetix_sdk-0.3.0-py3-none-any.whl (45.3 kB view details)

Uploaded Python 3

File details

Details for the file synthetix_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: synthetix_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 66.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for synthetix_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 582719a48dafa6bcfea48bf54426dc7e37279c1902170760e489ef6652c87418
MD5 7661cb406c0408d78eb2c918de4848ec
BLAKE2b-256 3bad3f9c777002e4159ea38636b4ecbffdad21d58848d98699034d9c762fbf55

See more details on using hashes here.

File details

Details for the file synthetix_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: synthetix_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 45.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for synthetix_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3ba45910488d97f4683ba9c5afb7ba3ee5f5ebac43a09605181021f8c0d5109
MD5 3077a9fb48fc2da614b76c09da0caac6
BLAKE2b-256 a215b921f4ea0ab9db030ee4561a6fdb42868e145f5e9ce607cd31aa70fba79e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page