Authentication

All GoDark API endpoints use a single authentication model: long-lived api_key + api_secret + passphrase credentials are exchanged for a short-lived bearer token via OAuth 2.0 client_credentials.

Credential Model

LayerCredentialLifetimePurpose
Long-livedapi_key + api_secret + passphraseUntil rotatedIdentify your account. The passphrase is set by you at key-creation time and must be supplied with every token exchange — it is not recoverable if lost.
Short-livedaccess_token (JWT Bearer)15 minutesSent with every REST request and on WebSocket login.

Generate and manage api_key / api_secret / passphrase triples from the app under Settings → API Keys. The passphrase is shown once at creation time; if you lose it, rotate the key.

POST /auth/token

Exchange credentials for a bearer token. RFC 6749 client_credentials grant.

POST /api/v1/auth/token

Request

Content-Type: application/json
{
  "grant_type": "client_credentials",
  "client_id": "<api_key>",
  "client_secret": "<api_secret>",
  "passphrase": "<passphrase>"
}

Response

{
  "access_token": "eyJhbGciOi...",
  "token_type": "Bearer",
  "expires_in": 900,
  "scope": "trade read"
}
FieldDescription
access_tokenShort-lived JWT bearer token.
token_typeAlways Bearer.
expires_inToken lifetime in seconds (default 900 = 15 min).
scopeSpace-separated list of granted scopes (trade, read).

cURL

curl -X POST https://api.godarkdex.com/api/v1/auth/token \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "client_credentials",
    "client_id": "YOUR_API_KEY",
    "client_secret": "YOUR_API_SECRET",
    "passphrase": "YOUR_PASSPHRASE"
  }'

POST /auth/token/revoke

Invalidate an access token before its natural expiry. RFC 7009.

POST /api/v1/auth/token/revoke

Request

{
  "token": "eyJhbGciOi..."
}

Response

204 No Content on success. Revoking an already-expired or unknown token is a no-op and also returns 204.

Using the Bearer Token

Every subsequent REST request must include:

Authorization: Bearer <access_token>

For WebSocket, authenticate the socket with an op: "login" frame carrying the same token — see WebSocket Trading.

Token Expiry

Access tokens expire after 15 minutes. On expiry:

Public (Unauthenticated) Endpoints

The following endpoints do not require a bearer token:

All other endpoints require Authorization: Bearer <token>.

Errors

StatusCodeMeaning
400invalid_requestMalformed request (missing grant_type, passphrase, bad JSON).
400unsupported_grant_typeOnly client_credentials is supported.
401invalid_clientUnknown client_id, bad client_secret, or bad passphrase.
401token_expiredBearer token is past its expires_in window.
401token_revokedToken was revoked via /auth/token/revoke.
403insufficient_scopeToken lacks the required scope for the endpoint.

See Error Codes for the full reference.