Get started

Authentication & Signing

To protect security and data integrity, the platform uses HMAC-SHA256 signature authentication. Every request to a private API must carry a signature and authentication details in its HTTP headers, or it is rejected. This authentication mechanism applies to all APIs that require identity verification.

Authentication parameters

Access credentials

Once your access application is approved, log in to the website to create an API key and sub-accounts.

  • The system automatically generates and issues an Access API Key and a SecretKey for API access and signature calculation.
  • You choose the ACCESS-PASSPHRASE when creating the API key; it serves as a security verification password when calling the API.
  • Keep the credentials above safe and never share them with anyone. If any of them leaks, regenerate the affected key immediately.

Once created, you will receive the following:

NameDescription
Access API keyAPI access token that identifies the caller.
SecretKeyPrivate key used to generate signatures. Keep it secret.
ACCESS-PASSPHRASEAPI password that adds an extra layer of verification.
Security warning — Use the SecretKey only to compute signatures locally. Never expose it in plain text in front-end code, logs or third-party environments.

Request headers (HTTP Header)

Every authenticated request must include these headers.

HeaderRequiredDescription
ACCESS-KEYYesAPI access token
ACCESS-SIGNYesRequest signature
ACCESS-TIMESTAMPYesRequest timestamp (milliseconds)
ACCESS-PASSPHRASEYesAPI passphrase

Timestamp rules

  • ACCESS-TIMESTAMP is a Unix timestamp in milliseconds.
  • Example: 1766066126559 (2025-12-18 21:56:09.622).
  • The platform validates the request time, so keep your server clock accurate.

Building the signature

Signature algorithm

  • HMAC-SHA256;
  • The signature result is Base64-encoded.

String to sign

Concatenate these fields in order:

timestamp + HTTP_METHOD + request_path + query_string + request_body

Concatenation rules:

FieldDescription
timestampRequest timestamp (milliseconds)
HTTP_METHODRequest method in upper case (GET / POST / PUT / DELETE)
request_pathURL path without the domain
query_stringQuery parameters in the URL, prefixed with “?” when present
request_bodyThe raw request body; an empty string when there is none
timestampHTTP_METHODrequest_pathquery_stringrequest_body

Notes

Request path

  • Contains only the path part
  • For example:
/api/v1/order/place

Query string

If the request has query parameters, they must be concatenated in their original order. For example:

?symbol=BTCUSDT&type=limit

Request body

  • Use the raw string.
  • For a JSON request body, the field order and formatting must stay consistent.
  • If there is no body (for example, a GET request), use an empty string.

Implementation example

JS version

import crypto from "node:crypto";
const API_KEY = process.env.OSL_API_KEY;
const SECRET_KEY = process.env.OSL_SECRET_KEY;
const PASSPHRASE = process.env.OSL_PASSPHRASE;
// query: "symbol=BTCUSDT&type=limit" (without "?"), body: raw JSON string or ""
export function signHeaders(method, path, query = "", body = "") {
const timestamp = Date.now().toString();
const prehash = timestamp + method.toUpperCase() + path + (query ? "?" + query : "") + body;
const signature = crypto.createHmac("sha256", SECRET_KEY).update(prehash).digest("base64");
return {
"ACCESS-KEY": API_KEY,
"ACCESS-SIGN": signature,
"ACCESS-TIMESTAMP": timestamp,
"ACCESS-PASSPHRASE": PASSPHRASE,
"Content-Type": "application/json",
};
}

Java version

Java
public static void main(String[] args) throws Exception {
String secret = "5aed2291abf14a55c06bb14e311abf1f5458f8077209f6bbb2a8118d176d8d76";
String timestamp = System.currentTimeMillis()+"";
String method = "GET";
String path = "/api/v3/time";
String query = null;
String body = null;
StringBuilder stringToSign = new StringBuilder();
stringToSign.append(timestamp)
.append(method.toUpperCase())
.append(path);
if (query != null && !query.isEmpty()) {
stringToSign.append("?").append(query);
}
if (body != null) {
stringToSign.append(body);
}
String sign = ApiSignUtil.generateSignature(stringToSign.toString(), secret);
System.out.println( sign);
}
public static String generateSignature(String body, String secret) {
try {
// HMAC-SHA256
Mac mac = Mac.getInstance(HMAC_SHA256);
SecretKeySpec secretKey =
new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), HMAC_SHA256);
mac.init(secretKey);
byte[] rawHmac = mac.doFinal(
body.getBytes(StandardCharsets.UTF_8)
);
// Base64 编码
return Base64.getEncoder().encodeToString(rawHmac);
} catch (Exception e) {
throw new RuntimeException("Failed to generate API signature", e);
}
}