SDKs
Official GoDark client libraries for programmatic trading. Each SDK implements the same public API documented in REST API and WebSocket API — including OAuth2 authentication, ECDH session setup, and AES-GCM encrypted order payloads.
SDK distribution is currently limited to approved integrators. Contact GoDark for access. Public package registries (PyPI, npm, crates.io, pkg.go.dev, Maven Central) will be announced when general availability opens.
Languages
| Language | Package (planned) | 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++17 | Beta |
| Go | github.com/gq-godark/gdx-go-sdk | Go 1.22+ | Beta |
| Java | exchange.godark:godark | JDK 17+ | Beta |
Choose a client
| Client | Transport | Best for |
|---|---|---|
GodarkRestClient | HTTPS (/api/v1/*) | REST-only bots, simpler deployments, matches Place Order semantics |
GodarkClient | WebSocket (/ws/v1) | Low-latency trading, multiplexed order + position streams |
MarketDataClient | WebSocket (/ws/gomarket) | External venue reference data — not GoDark's internal order book |
All trading clients handle auth token exchange, ECDH session setup, and order encryption automatically. See Authentication and Encryption & Transport for the underlying protocol.
Environment variables
| Variable | Required | Description |
|---|---|---|
GDX_API_KEY_ID | Yes | API key id from onboarding (client_id) |
GDX_API_SECRET | Yes | API secret (client_secret) |
GDX_REST_URL | No | REST base URL. Default: https://api.godarkdex.com |
GDX_EDGE_URL / GODARK_EDGE_URL | No | WebSocket host origin. SDK appends /ws/v1 automatically |
GDX_PASSPHRASE | No | Passphrase if your key requires it (see Authentication) |
Local development typically uses GDX_REST_URL=http://127.0.0.1:4000 and GDX_EDGE_URL=ws://127.0.0.1:4000.
Network endpoints
| Network | REST | WebSocket |
|---|---|---|
| Mainnet | https://api.godarkdex.com/api/v1 | wss://api.godarkdex.com/ws/v1 |
| Testnet | https://api.godarkdex-testnet.com/api/v1 | wss://api.godarkdex-testnet.com/ws/v1 |
| Localnet | http://127.0.0.1:4000/api/v1 | ws://127.0.0.1:4000/ws/v1 |
Pass either a bare host (https://api.godarkdex.com) or the full /api/v1 / /ws/v1 path — SDKs normalize both forms.
REST trading flow
Every SDK follows the same sequence for encrypted REST orders:
POST /auth/token— exchangeapi_key_id+api_secretfor a 15-minute bearer tokenPOST /session/setup— ECDH key exchange; derive AES-256-GCM session key- Encrypted
POST /orders,DELETE /orders/{id},PATCH /orders/{id}— protobuf payloads with GCM AAD
WebSocket clients perform the same auth + session setup over the multiplexed socket before order.place / order.cancel ops.
Error handling
All SDKs expose typed errors that map to Error Codes:
| Error | Typical cause |
|---|---|
AuthenticationError | Invalid or expired credentials (1000–1006) |
SessionError | ECDH / session setup failure |
EncryptionError | Encrypt/decrypt or framing error |
OrderError | Risk rejection or trading error (1410–1413, 1400–1407) |
TimeoutError | Await/poll exceeded deadline |
ConnectionError | Network or WebSocket disconnect |
Related documentation
- Programmatic Access — getting started with the API
- Trading Concepts — order types, TIF, execution attributes (read before placing orders)
- Rules & Limits — rate limits and trade protection