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

ItemDetails
API keyStarts with pk_; sent with each request to identify your account
SecretStarts with sk_; used only to compute signatures — never send it
LimitUp to 5 API keys per account, e.g. one per product line
ManagementUnder “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

HeaderRequiredDescription
X-API-KEYYesYour API key
X-API-TIMESTAMPYesCurrent time in milliseconds, e.g. 1763100000000
X-API-SIGNYesRequest signature, lowercase hex
Content-TypeFor POSTapplication/json
Accept-LanguageNoLanguage of error messages: zh (default) or en

Computing the signature

Text
sign = hex( HMAC-SHA256( Secret, timestamp + METHOD + pathWithQuery + body ) )
PartDescription
timestampExactly the same string as X-API-TIMESTAMP
METHODUppercase HTTP method: GET or POST
pathWithQueryPath 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
bodyFor 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"

Test vectors

Use these to check your implementation. Secret is sk_test_0123456789abcdef, timestamp is 1700000000000.

RequestExpected signature
GET /api/open/v1/rate?from=USDT&fromNetwork=TRC20&to=BTC&toNetwork=Bitcoin&amount=100, empty body0e643b0f0d966604de2deb85fe99ba6dec2cc93441733bddf203e82b2875c43c
POST /api/open/v1/orders, body below018f24bb0e4112bf1c8bef91a5f07a24b831d5e9bc455ca44c3c7956f690a608
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:

messageCause and fix
missing X-API-KEY / X-API-TIMESTAMP / X-API-SIGNA header is missing
invalid API keyThe API key doesn't exist or was deleted
API key disabledThe key has been disabled
IP x.x.x.x is not in the whitelistThe 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 mismatchWrong 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]