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.

LanguageExamples repoClone
Pythongdx-python-sdk-examplesgit clone https://github.com/gq-godark/gdx-python-sdk-examples.git
Rustgdx-rust-sdk-examplesgit clone https://github.com/gq-godark/gdx-rust-sdk-examples.git
JavaScript / TypeScriptgdx-js-sdk-examplesgit clone https://github.com/gq-godark/gdx-js-sdk-examples.git
C++gdx-cpp-sdk-examplesgit clone https://github.com/gq-godark/gdx-cpp-sdk-examples.git
Gogdx-go-sdk-examplesgit clone https://github.com/gq-godark/gdx-go-sdk-examples.git
Javagdx-java-sdk-examplesgit 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

LanguagePackageRequirementsStatus
PythongodarkPython 3.10+Beta
RustgodarkRust 2021, tokioBeta
JavaScript / TypeScript@godark/sdkNode.js 18+Beta
C++godark headersC++20Beta
Gogithub.com/gq-godark/gdx-go-sdkGo 1.22+Beta
Javavendored godark-*-all.jarJDK 17+Beta

Choose a client

ClientTransportBest for
GodarkClientWebSocket (/ws/v1)Encrypted trading: place / cancel / modify, mass quote, batch cancel, order + position streams
GodarkRestClientHTTPS (/api/v1)Bearer auth + one-shot HPKE for trading, account, positions, leverage, and public-market queries
MarketDataClientWebSocketPublic 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).

VariableRequiredDescription
GODARK_API_KEY_IDYesAPI key id (client_id)
GODARK_API_SECRETYesAPI secret (client_secret)
GODARK_PASSPHRASEYesPassphrase for the key pair
GODARK_ACCOUNTNo32-byte account, base58. The token subject is used when omitted
GODARK_EDGE_URLNoWebSocket origin override
GODARK_REST_URLNoREST origin override
GDX_HPKE_STATIC_PUBLIC_KEYNoHPKE 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:

  1. Connect to /ws/v1 with GODARK_API_KEY_ID, GODARK_API_SECRET, and GODARK_PASSPHRASE
  2. The SDK mints a REST access token via POST /api/v1/auth/token (grant_type=client_credentials), then sends WebSocket login with that access_token. It reads the 32-byte account and the unsigned 64-bit conn_id, runs HPKE Base setup, and derives AES-256-GCM session keys.
  3. Subscribe to orders (book confirmation waits on private order updates)
  4. 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.

ErrorTypical cause
AuthenticationErrorInvalid credentials or failed WS login
SessionErrorHPKE setup or session failure (including missing 32-byte account / conn_id)
EncryptionErrorEncrypt/decrypt or framing error
OrderErrorVenue risk rejection or trading error (symbolic error_code when present)
TimeoutErrorAwait/poll exceeded deadline
ConnectionErrorNetwork 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(...).