All Binance Web3 API endpoints are protected by API Key authentication. Each request must be
signed using your Secret Key, ensuring that only authorized clients with valid credentials can
access the platform.
Step 1 â Obtain API Credentials
Visit the Developer Portal to create a project
and generate an API Key and Secret Key:
Credential
Description
API Key
Uniquely identifies your application (X-OC-APIKEY header)
Secret Key
Used to sign requests (HMAC-SHA256 mode). Keep this private.
Step 2 â Understand Required Headers
Every authenticated request must include the following three headers:
Header
Required
Description
X-OC-APIKEY
Yes
Your API Key string
X-OC-TIMESTAMP
Yes
Current UTC time in ISO 8601 format with milliseconds, e.g. 2026-05-11T10:08:57.715Z
Allowed time deviation in milliseconds (default: 5000, max: 60000)
X-OC-NONCE
No
Unique request identifier for anti-replay; falls back to X-OC-SIGN if omitted
Step 3 â Generate the Signature
3.1 Build the Pre-Hash String
Concatenate the following four components without any separator:
Code
preHash = timestamp + method + requestPath + body
Component
Rule
timestamp
Exact value of the X-OC-TIMESTAMP header (ISO 8601, e.g. 2026-05-11T10:08:57.715Z)
method
HTTP method in UPPERCASE (e.g. GET, POST)
requestPath
Full HTTP path (including any base-path prefix) plus query string in raw URL-encoded form, e.g. /build/api/v1/dex/market/price?chainId=1&symbol=ETH%20USDT
body
Raw request body string for POST/PUT/DELETE; empty string "" for GET/HEAD
Critical:requestPath must use the exact raw-encoded form as sent on the
HTTP wire â no percent-decoding, no query-parameter re-ordering, no parameter
merging.
Attach the three required headers to every authenticated request:
Code
GET /api/v1/dex/market/price?chainId=1&symbol=ETH%20USDT HTTP/1.1Host: web3.binance.com/buildX-OC-APIKEY: your-api-key-hereX-OC-TIMESTAMP: 2026-05-11T10:08:57.715ZX-OC-SIGN: k3Y2mNpQr...base64sig...==
Complete JavaScript Example
Code
const crypto = require("crypto");const axios = require("axios");const API_KEY = process.env.OC_API_KEY;const SECRET_KEY = process.env.OC_SECRET_KEY;const BASE_URL = "https://web3.binance.com";async function get(path, params = {}) { // Use encodeURIComponent so spaces become %20 (not +), matching the raw wire encoding const queryStr = Object.entries(params) .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`) .join("&"); const fullPath = queryStr ? `${path}?${queryStr}` : path; const timestamp = new Date().toISOString(); // requestPath is the full path as sent on the wire (already includes /build prefix) const requestPath = fullPath; const body = ""; // empty string for GET requests const preHash = timestamp + "GET" + requestPath + body; const signature = crypto .createHmac("sha256", SECRET_KEY) .update(preHash, "utf8") .digest("base64"); const resp = await axios.get(BASE_URL + fullPath, { headers: { "X-OC-APIKEY": API_KEY, "X-OC-TIMESTAMP": timestamp, "X-OC-SIGN": signature, }, }); return resp.data;}// Usageget("/build/api/v1/dex/aggregator/supported/chain", { binanceChainId: "56",}).then(console.log);
Timestamp & Anti-Replay
The gateway validates X-OC-TIMESTAMP on every authenticated request:
Format: Must be a valid ISO 8601 string (e.g. 2026-05-11T10:08:57.715Z).
Time window: The request timestamp must be within recv_window milliseconds of server time.
Default is 5 000 ms (5 s), configurable via X-OC-RECV-WINDOW (max 60 000 ms / 60 s).
Anti-replay: Each nonce (X-OC-NONCE or the signature itself) is valid only once within the
2 Ã recv_window time window. Replayed requests are rejected with error 40103.
Keep your system clock synchronized with an NTP server to avoid timestamp
drift errors.
Rate Limits
Authenticated requests are subject to four concurrent rate-limit dimensions:
Dimension
Default Limit
Window
Response Header
Per IP
1 200 requests
60 s
X-OC-RateLimit-Limit
Per API Key
1 200 requests
60 s
X-OC-RateLimit-Remaining
Per User
6 000 requests
60 s
X-OC-Used-Weight
Per Endpoint
5 RPS (default)
1 s
X-OC-Used-Weight
When a limit is exceeded the gateway returns HTTP 429 with a Retry-After header (in seconds).