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 |
X-OC-SIGN | Yes | Request signature (Base64-encoded), see Step 3 |
X-OC-RECV-WINDOW | No | 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 |
Base URL & Required /build Prefix
All endpoints are served from the same host with a fixed /build base path:
Code
This means every request line on the HTTP wire starts with /build/api/v1/..., and the
requestPath used in the signature (see Step 3) must also include the /build prefix â exactly
as it appears on the wire.
Critical â the #1 cause of 40102 Invalid signature: omitting the
/build prefix from the signed requestPath. A bare /api/v1/... in the
signature string will fail signature verification even if the request itself
is routed correctly. Always prefix the path with /build when building the
pre-hash string.
| What | Value / Rule |
|---|---|
| Base URL | https://web3.binance.com/build |
| Full request URL | https://web3.binance.com/build + /api/v1/... |
Signed requestPath | /build/api/v1/... (+ ?query if present) |
Host header | web3.binance.com (no path) |
A bare https://web3.binance.com/api/v1/... (without /build) is redirected to the /build prefix
at the edge â do not rely on that for signing. Always include /build explicitly in both the
request URL and the signed requestPath.
Step 3 â Generate the Signature
3.1 Build the Pre-Hash String
Concatenate the following four components without any separator:
Code
| 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 the /build base-path prefix plus query string, in raw URL-encoded form, e.g. /build/api/v1/dex/market/price?chainId=1&symbol=ETH%20USDT. See Base URL. |
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. It must start with the /build prefix; omitting it is the most
common cause of 40102 Invalid signature.
Example (GET request)
Code
Example (POST request)
Code
3.2 Sign with HMAC-SHA256 (Default)
Compute HMAC-SHA256 over preHash using your Secret Key, then Base64-encode the result:
Code
All strings are UTF-8 encoded before hashing.
JavaScript / Node.js
Code
Python
Code
Java
Code
Step 4 â Send the Request
Attach the three required headers to every authenticated request:
Code
Complete JavaScript Example
Code
Whichever style you choose â passing /build/... paths explicitly, or letting
a helper prepend /build â the key requirement is that the signed
requestPath and the request URL both carry the /build prefix. Mixing
the two (e.g. signing without /build but sending with it) will produce
40102 Invalid signature.
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_windowmilliseconds of server time. Default is 5 000 ms (5 s), configurable viaX-OC-RECV-WINDOW(max 60 000 ms / 60 s). - Anti-replay: Each nonce (
X-OC-NONCEor the signature itself) is valid only once within the2 Ã recv_windowtime window. Replayed requests are rejected with error40103.
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).
Error Codes
| HTTP Status | Error Code | Meaning |
|---|---|---|
| 400 | 40001 | Invalid request parameters |
| 401 | 40101 | API Key is missing, invalid, or disabled |
| 401 | 40102 | Signature mismatch or missing |
| 401 | 40103 | Timestamp expired or request replayed |
| 403 | 40104 | API Key lacks required permission |
| 429 | 42900 | Rate limit exceeded |
| 500 | 50000 | Internal server error |
| 503 | 50001 | Service temporarily unavailable |
All error responses follow the unified format:
Code
Postman Quick Start
Add the following Pre-request Script to your Postman collection to auto-sign every request. In
your collection, set the base URL to https://web3.binance.com/build and configure every request
path as /api/v1/... â the script below prepends /build to the path when building the signature
so the signed requestPath matches what is sent on the wire.
Code
Set api_key and secret_key under Collection â Variables and every request will be signed
automatically.