Java SDK

Encrypted Java client for the GoDark API. Maven coordinates: exchange.godark:godark.

Requirements: JDK 17+
Status: Beta — contact GoDark for SDK access.

Installation

Public Maven Central release is not yet available. Approved integrators receive distribution instructions directly.

When published:

dependencies {
    implementation("exchange.godark:godark:0.2.0")
}

Build from source at the SDK root (requires gdx-proto submodule):

./gradlew check
./gradlew shadowJar   # build/libs/godark-<version>-all.jar

Quickstart

Set credentials, then place a limit order over encrypted REST:

import godark.GodarkRestClient;
import godark.Types;

public class Quickstart {
  public static void main(String[] args) throws Exception {
    GodarkRestClient client =
        GodarkRestClient.builder()
            .apiKeyId(System.getenv("GDX_API_KEY_ID"))
            .apiSecret(System.getenv("GDX_API_SECRET"))
            .passphrase(System.getenv("GDX_PASSPHRASE"))
            .restBaseUrl(GodarkRestClient.resolveRestBaseUrl(System.getenv("GDX_REST_URL")))
            .build();

    client.connect();
    try {
      Types.OrderAck ack =
          client.placeOrder(
              "BTC-USDC-PERP",
              "BUY",
              "LIMIT",
              0.01,
              95000.0,
              "GTC",
              false,
              null,
              null,
              "my-first-order");
      System.out.println("placed " + ack.orderId());
    } finally {
      client.close();
    }
  }
}

See Place Order for all request fields.

Clients

ClassDescription
GodarkRestClientREST-only encrypted trading
GodarkClientWebSocket trading + streams
MarketDataClientExternal venue feeds on /ws/gomarket

Build GodarkRestClient with GodarkRestClient.builder(): .apiKeyId(), .apiSecret(), .passphrase(), .restBaseUrl().

GodarkRestClient methods

MethodDocs reference
connect() / close()Authentication, Encryption
placeOrder(...)Place Order
cancelOrder(orderId, symbol)Cancel Order
cancelOrderByClientId(clientOrderId, symbol)Cancel Order
modifyOrder(...)Modify Order
getOrder(orderId)Get Order
getOrderByClientOrderId(clientOrderId)Get Order
getMe() / getMyBalance()Account Info
awaitTerminalStatus(orderId, timeoutSec, pollIntervalSec)Poll until terminal order state

GodarkClient (WebSocket)

CapabilityDocs reference
placeOrder, cancelOrder, modifyOrderWebSocket Trading
Order and position update handlersOrders Channel, User Events

Types and errors

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

Environment variables accept GDX_* or GODARK_* prefixes. Optional .env at the repository root is loaded by EnvFiles for local samples.

Bundled examples

Gradle tasks under the examples group:

TaskDescription
runQuickstartWebSocket: subscribe, place, cancel
runRestQuickstartREST: auth + one limit order
runMarketDataSampleGoMarket orderbook frame
runTraderFlowSampleWebSocket place, modify, cancel
./gradlew tasks --group=examples
./gradlew runRestQuickstart

See also