Python SDK

Encrypted Python client for the GoDark API. Package name: godark.

Requirements: Python 3.10+
Status: Beta — clone the public examples repo to get started.

Get the SDK

Clone gdx-python-sdk-examples. The repo vendors the godark SDK under sdk/ (and an optional wheel under wheels/) so no private PyPI registry is required:

git clone https://github.com/gq-godark/gdx-python-sdk-examples.git
cd gdx-python-sdk-examples
cp .env.example .env
# set GODARK_API_KEY_ID, GODARK_API_SECRET, GODARK_PASSPHRASE

bash scripts/setup_venv.sh
source .venv/bin/activate
cd examples && python quickstart.py

You can also point an LLM / coding agent at the cloned repo and ask it to build a strategy using your credentials in .env. See the repo README for full setup, examples, and packaging details.

Public PyPI release is not yet available; until then this repo is the supported distribution.

Quickstart

Set credentials, then place a limit order over encrypted WebSocket (GodarkClient). Subscribe to orders before placing so book confirmation can wait on private updates. Limit prices must stay near the oracle or the venue rejects — see Error Codes.

import asyncio
import os

from godark import Environment, GodarkClient, OrderType, Side, TimeInForce

SYMBOL = "BTC-USDC-PERP"


async def main() -> None:
    kwargs = dict(
        api_key_id=os.environ["GODARK_API_KEY_ID"],
        api_secret=os.environ["GODARK_API_SECRET"],
        passphrase=os.environ["GODARK_PASSPHRASE"],
        environment=Environment.TESTNET,
    )
    if edge := os.environ.get("GODARK_EDGE_URL", "").strip():
        kwargs["base_url"] = edge

    async with GodarkClient(**kwargs) as client:
        await client.subscribe(["orders"])
        ack = await client.place_order(
            SYMBOL,
            Side.SELL,
            OrderType.LIMIT,
            0.01,
            price=68_000.0,  # within ~10% of oracle
            time_in_force=TimeInForce.GTC,
        )
        print("placed", ack.order_id)
        await asyncio.sleep(0.5)
        cancel = await client.cancel_order(str(ack.order_id), SYMBOL)
        print("cancelled", cancel.order_id)


asyncio.run(main())

See WebSocket Trading and Place Order for request fields.

Clients

ClassDescription
GodarkClientWebSocket trading + order/position streams on /ws/v1
MarketDataClientExternal venue feeds on /ws/gomarket

GodarkRestClient may still be exported for residual HTTP helpers; encrypted order place / cancel / modify is WebSocket-only.

GodarkClient methods

MethodDocs reference
connect() / disconnect()Authentication, Encryption
subscribe(...)WebSocket Trading
place_order(...)Place Order, WebSocket Trading
cancel_order(...)Cancel Order
modify_order(...)Modify Order
mass_quote(...)Mass Quote
batch_cancel(...)Cancel Order
Order update callbacksOrders Channel
Position update callbacksPositions Channel

Types and errors

Exported from godark: Environment, Side, OrderType, TimeInForce, OrderStatus, OrderAck, OrderUpdate, PositionUpdate, and error classes (AuthenticationError, SessionError, OrderError, EncryptionError, TimeoutError, ConnectionError).

Environment variables: OS GODARK_*, then OS GDX_*, then .env GODARK_*, then .env GDX_*. The process environment always wins over .env. Quickstart snippets use the canonical GODARK_* names.

Bundled examples

Runnable samples in the examples repo include quickstart.py (connect → subscribe → place → cancel) and full_trader_example.py (modify, mass quote, batch cancel).

See also