SDKs
Official GoDark client libraries for programmatic trading. Each SDK implements the same public API documented in REST API and WebSocket API. Trading clients authenticate with API key id + secret + passphrase, establish an HPKE session, and send AES-GCM encrypted order payloads — see Authentication and Encryption & Transport.
Get started
Clone a language examples repo locally. Each repo vendors the SDK (source, wheel, JAR, or static library) so you do not need a private package registry. Add your API key, secret, and passphrase, then run the samples — or point an LLM / coding agent at the cloned repo to build a strategy.
| Language | Examples repo | Clone |
|---|---|---|
| Python | gdx-python-sdk-examples | git clone https://github.com/gq-godark/gdx-python-sdk-examples.git |
| Rust | gdx-rust-sdk-examples | git clone https://github.com/gq-godark/gdx-rust-sdk-examples.git |
| JavaScript / TypeScript | gdx-js-sdk-examples | git clone https://github.com/gq-godark/gdx-js-sdk-examples.git |
| C++ | gdx-cpp-sdk-examples | git clone https://github.com/gq-godark/gdx-cpp-sdk-examples.git |
| Go | gdx-go-sdk-examples | git clone https://github.com/gq-godark/gdx-go-sdk-examples.git |
| Java | gdx-java-sdk-examples | git clone https://github.com/gq-godark/gdx-java-sdk-examples.git |
Public package registries (PyPI, npm, crates.io, pkg.go.dev, Maven Central) may be announced later. Until then, the examples repos are the supported way to get the SDKs.
Languages
| Language | Package | Requirements | Status |
|---|---|---|---|
| Python | godark | Python 3.10+ | Beta |
| Rust | godark | Rust 2021, tokio | Beta |
| JavaScript / TypeScript | @godark/sdk | Node.js 18+ | Beta |
| C++ | godark headers | C++20 | Beta |
| Go | github.com/gq-godark/gdx-go-sdk | Go 1.22+ | Beta |
| Java | vendored godark-*-all.jar | JDK 17+ | Beta |
Choose a client
| Client | Transport | Best for |
|---|---|---|
GodarkClient | WebSocket (/ws/v1) | Encrypted trading: place / cancel / modify, mass quote, batch cancel, order + position streams |
GodarkRestClient | HTTPS (/api/v1) | Bearer auth + one-shot HPKE for trading, account, positions, leverage, and public-market queries |
MarketDataClient | WebSocket | Public volume, open_interest, and funding_rate on /ws/v1. Order-book and trade streams use the market-data socket configured for your client |
GodarkClient handles WS login, HPKE session setup, and order encryption automatically. GodarkRestClient exchanges credentials at POST /auth/token, then seals each trading body with one-shot HPKE.
Environment variables
Copy .env.example to .env in the cloned examples repo (Java: examples/.env).
| Variable | Required | Description |
|---|---|---|
GODARK_API_KEY_ID | Yes | API key id (client_id) |
GODARK_API_SECRET | Yes | API secret (client_secret) |
GODARK_PASSPHRASE | Yes | Passphrase for the key pair |
GODARK_ACCOUNT | No | 32-byte account, base58. The token subject is used when omitted |
GODARK_EDGE_URL | No | WebSocket origin override |
GODARK_REST_URL | No | REST origin override |
GDX_HPKE_STATIC_PUBLIC_KEY | No | HPKE static public key when the SDK preset does not include one |
Resolution order for each setting: OS GODARK_*, then OS GDX_*, then .env GODARK_*, then .env GDX_*. The process environment always wins over .env in every language, including Java (examples/.env is only used when neither OS alias is set). Language pages use the same order; quickstart snippets show the canonical GODARK_* names.
See Endpoints for paths. Language pages list every public method and field.
WebSocket trading flow
Every SDK follows the same sequence for encrypted orders:
- Connect to
/ws/v1withGODARK_API_KEY_ID,GODARK_API_SECRET, andGODARK_PASSPHRASE - The SDK mints a REST access token via
POST /api/v1/auth/token(grant_type=client_credentials), then sends WebSocketloginwith thataccess_token. It reads the 32-byte account and the unsigned 64-bitconn_id, runs HPKE Base setup, and derives AES-256-GCM session keys. - Subscribe to
orders(book confirmation waits on private order updates) place_order/cancel_order/modify_order(and mass quote / batch cancel) over the multiplexed socket
Sealed plaintext is the bare inner protobuf (PlaceOrderInput, …), selected by clear header request_type — not EdgeSequencerRequest. Across SDKs, public place / modify / mass-quote / batch-modify / TP-SL prices, sizes, quote notional, min fill, trigger, take-profit, and stop-loss are decimal strings only (for example "67500.5", "0.01"). Numbers and floats are rejected. The same string form is sealed on the wire and validated against each instrument’s price_decimals / quantity_decimals from GET /api/v1/instruments. Time-in-force strings: GTC, IOC, FOK, GTD. Optional slippage_bps on market / stop-market. Every SDK place call accepts exactly one size: base quantity or quote_notional.
See WebSocket Trading. Limit prices must stay near the oracle or the venue rejects — see Error Codes.
Error handling
All SDKs expose typed errors. WebSocket rejects carry a numeric error_code and a symbolic name — see Error Codes. Python, JavaScript, C++, and Go use language-specific error classes/types; Java uses GodarkException, SessionException, OrderRejectedException, and similar. Rust returns Result<T, GodarkError> with enum variants rather than exception classes.
| Error | Typical cause |
|---|---|
AuthenticationError | Invalid credentials or failed WS login |
SessionError | HPKE setup or session failure (including missing 32-byte account / conn_id) |
EncryptionError | Encrypt/decrypt or framing error |
OrderError | Venue risk rejection or trading error (symbolic error_code when present) |
TimeoutError | Await/poll exceeded deadline |
ConnectionError | Network or WebSocket disconnect |
Rust equivalents are GodarkError::Authentication(String), Session(String), Order { message, error_code, user_message }, Connection(String), Encryption(String), Timeout(String), Config(String), InvalidInput(String), WebSocket(...), and Proto(...).
Related documentation
- Programmatic Access — getting started with the API
- Agent Access — MCP server and CLI for coding agents
- Trading Concepts — order types, TIF, execution attributes (read before placing orders)
- Rules & Limits — rate limits and trade protection