Java SDK

Encrypted Java client for the GoDark API. Distributed as a shaded godark-*-all.jar (not published to Maven Central yet).

Requirements: JDK 17+
Status: Beta — clone the public examples repo to get started.

Get the SDK

Clone gdx-java-sdk-examples. The repo vendors a shaded godark-*-all.jar under sdk/lib/ so no private Maven registry is required:

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

cd examples
./gradlew --no-daemon runQuickstart
./gradlew --no-daemon runFullTraderExample

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

Public Maven Central 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 godark.Environment;
import godark.GodarkClient;
import godark.Types;

public class Quickstart {
  public static void main(String[] args) throws Exception {
    GodarkClient.Builder b =
        GodarkClient.builder()
            .environment(Environment.TESTNET)
            .apiKeyId(System.getenv("GODARK_API_KEY_ID"))
            .apiSecret(System.getenv("GODARK_API_SECRET"))
            .passphrase(System.getenv("GODARK_PASSPHRASE"));
    String edge = System.getenv("GODARK_EDGE_URL");
    if (edge != null && !edge.isBlank()) {
      b.baseUrl(edge);
    }

    GodarkClient client = b.build();
    try {
      client.connect();
      client.subscribe("orders");
      Types.OrderAck ack =
          client.placeOrder(
              "BTC-USDC-PERP",
              "SELL",
              "LIMIT",
              0.01,
              68000.0, // within ~10% of oracle
              "GTC",
              false,
              null,
              null);
      System.out.println("placed " + ack.orderId());
      Thread.sleep(500);
      Types.OrderAck cancel = client.cancelOrder(ack.orderId(), "BTC-USDC-PERP");
      System.out.println("cancelled " + cancel.orderId());
    } finally {
      client.disconnect();
    }
  }
}

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

Build GodarkClient with GodarkClient.builder(): .apiKeyId(), .apiSecret(), .passphrase(), .environment(). 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
placeOrder(...)Place Order, WebSocket Trading
cancelOrder(orderId, symbol)Cancel Order
modifyOrder(...)Modify Order
massQuote(...)Mass Quote
batchCancel(...)Cancel Order
Order update callbacksOrders Channel
Position update callbacksPositions Channel

Types and errors

Public API lives in the godark package: Environment, Enums, Types, Proto, and exception types (GodarkException, SessionException, OrderRejectedException, EncryptionException, etc.). See Error Codes.

Environment variables: OS GODARK_*, then OS GDX_*, then .env GODARK_*, then .env GDX_*. The process environment always wins over .env. Gradle samples load examples/.env only for keys not already exported. The snippet uses System.getenv with canonical GODARK_* names; runQuickstart also reads examples/.env.

Bundled examples

Gradle tasks under the examples group in the examples repo:

TaskDescription
runQuickstartConnect, subscribe, place, cancel
runFullTraderExamplePlace / modify / cancel, mass-quote / batch-cancel
./gradlew tasks --group=examples
./gradlew --no-daemon runQuickstart

See also