Getting started
Authentication
Every request must be signed. The signature proves the request comes from you (the holder of the Secret) and that its contents weren't altered. The SDKs sign automatically; this page is for implementing signatures yourself.
API key and Secret
| Item | Details |
|---|---|
| API key | Starts with pk_; sent with each request to identify your account |
| Secret | Starts with sk_; used only to compute signatures — never send it |
| Limit | Up to 5 API keys per account, e.g. one per product line |
| Management | Under “API” you can change the callback URL and IP whitelist, or disable and delete keys |
If you suspect a Secret has leaked, disable or delete that key under “API” immediately and create a new one.
Headers
| Header | Required | Description |
|---|---|---|
X-API-KEY | Yes | Your API key |
X-API-TIMESTAMP | Yes | Current time in milliseconds, e.g. 1763100000000 |
X-API-SIGN | Yes | Request signature, lowercase hex |
Content-Type | For POST | application/json |
Accept-Language | No | Language of error messages: zh (default) or en |
Computing the signature
Text
sign = hex( HMAC-SHA256( Secret, timestamp + METHOD + pathWithQuery + body ) )| Part | Description |
|---|---|
timestamp | Exactly the same string as X-API-TIMESTAMP |
METHOD | Uppercase HTTP method: GET or POST |
pathWithQuery | Path plus query string, e.g. /api/open/v1/rate?from=USDT&amount=100. It must match what you send exactly, including parameter order and encoding |
body | For POST, the exact JSON string you send; for GET, an empty string |
Notes:
- The bytes you sign must be exactly the bytes you send. Serialize the JSON once, then sign and send that same string.
- Encode query values per RFC 3986 (space becomes
%20). - The timestamp must be within 60 seconds of server time — keep your server clock synced.
- Each signature can be used only once. Resending an identical request (same timestamp and content) is rejected; generate a new timestamp and signature when retrying.
Examples
API_KEY="pk_..."
SECRET="sk_..."
TS=$(($(date +%s) * 1000))
PATH_Q="/api/open/v1/currencies"
SIGN=$(printf '%s' "${TS}GET${PATH_Q}" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')
curl "https://speed.cc${PATH_Q}" \
-H "X-API-KEY: $API_KEY" \
-H "X-API-TIMESTAMP: $TS" \
-H "X-API-SIGN: $SIGN"const crypto = require('crypto')
async function call(method, pathWithQuery, bodyObj) {
const body = bodyObj ? JSON.stringify(bodyObj) : ''
const ts = String(Date.now())
const sign = crypto.createHmac('sha256', process.env.SPEED_API_SECRET)
.update(ts + method + pathWithQuery + body).digest('hex')
const res = await fetch('https://speed.cc' + pathWithQuery, {
method,
headers: {
'X-API-KEY': process.env.SPEED_API_KEY,
'X-API-TIMESTAMP': ts,
'X-API-SIGN': sign,
'Content-Type': 'application/json'
},
body: method === 'POST' ? body : undefined
})
return res.json()
}import hashlib, hmac, json, os, time, urllib.request
def call(method, path_with_query, body_obj=None):
body = json.dumps(body_obj, separators=(",", ":")) if body_obj is not None else ""
ts = str(int(time.time() * 1000))
sign = hmac.new(os.environ["SPEED_API_SECRET"].encode(),
(ts + method + path_with_query + body).encode(), hashlib.sha256).hexdigest()
req = urllib.request.Request("https://speed.cc" + path_with_query, method=method,
data=body.encode() if method == "POST" else None)
req.add_header("X-API-KEY", os.environ["SPEED_API_KEY"])
req.add_header("X-API-TIMESTAMP", ts)
req.add_header("X-API-SIGN", sign)
req.add_header("Content-Type", "application/json")
with urllib.request.urlopen(req) as r:
return json.load(r)function speed_call(string $method, string $pathWithQuery, ?array $bodyObj = null): array {
$body = $bodyObj === null ? '' : json_encode($bodyObj, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$ts = (string) round(microtime(true) * 1000);
$sign = hash_hmac('sha256', $ts . $method . $pathWithQuery . $body, getenv('SPEED_API_SECRET'));
$ch = curl_init('https://speed.cc' . $pathWithQuery);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-KEY: ' . getenv('SPEED_API_KEY'),
'X-API-TIMESTAMP: ' . $ts,
'X-API-SIGN: ' . $sign,
'Content-Type: application/json',
],
]);
if ($method === 'POST') curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
return json_decode(curl_exec($ch), true);
}static String sign(String secret, String message) throws Exception {
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
return HexFormat.of().formatHex(mac.doFinal(message.getBytes(StandardCharsets.UTF_8)));
}
String ts = String.valueOf(System.currentTimeMillis());
String path = "/api/open/v1/currencies";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://speed.cc" + path))
.header("X-API-KEY", apiKey)
.header("X-API-TIMESTAMP", ts)
.header("X-API-SIGN", sign(secret, ts + "GET" + path))
.GET().build();func sign(secret, message string) string {
m := hmac.New(sha256.New, []byte(secret))
m.Write([]byte(message))
return hex.EncodeToString(m.Sum(nil))
}
ts := strconv.FormatInt(time.Now().UnixMilli(), 10)
path := "/api/open/v1/currencies"
req, _ := http.NewRequest("GET", "https://speed.cc"+path, nil)
req.Header.Set("X-API-KEY", apiKey)
req.Header.Set("X-API-TIMESTAMP", ts)
req.Header.Set("X-API-SIGN", sign(secret, ts+"GET"+path))Test vectors
Use these to check your implementation. Secret is sk_test_0123456789abcdef, timestamp is 1700000000000.
| Request | Expected signature |
|---|---|
GET /api/open/v1/rate?from=USDT&fromNetwork=TRC20&to=BTC&toNetwork=Bitcoin&amount=100, empty body | 0e643b0f0d966604de2deb85fe99ba6dec2cc93441733bddf203e82b2875c43c |
POST /api/open/v1/orders, body below | 018f24bb0e4112bf1c8bef91a5f07a24b831d5e9bc455ca44c3c7956f690a608 |
JSON
{"fromCurrency":"USDT","fromNetwork":"TRC20","toCurrency":"BTC","toNetwork":"Bitcoin","amount":"100","recipientAddress":"bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh","clientOrderId":"shop-1001"}Authentication errors
Authentication failures return HTTP 401 with code 40101; message gives the exact reason:
| message | Cause and fix |
|---|---|
missing X-API-KEY / X-API-TIMESTAMP / X-API-SIGN | A header is missing |
invalid API key | The API key doesn't exist or was deleted |
API key disabled | The key has been disabled |
IP x.x.x.x is not in the whitelist | The request IP isn't whitelisted — add it |
X-API-TIMESTAMP expired (more than 60s from server time) | Clock skew over 60 seconds — sync your server time |
signature mismatch | Wrong signature — check against the test vectors |
signature already used (replay) | Signature reused — generate a new timestamp and signature |
Need help with your integration? Contact support: [email protected]