Binance Web3 API Specification V0.0.6 (2024-01-09)
#
Web3 API description- Binance's Partners need to follow the API specification in this doc to provide Binance with a set of endpoints in order to integrate with Binance.
#
General API Information- All endpoints return a common JSON object with "code", "message" and "data", no matter it's a success or not.
- Here "data" is either a customized JSON object or a simple type (int, string...). it may vary from endpoint to endpoint.
General codes in responses:
code Description 000000 success 000001 too many requests 000002 system busy 000003 invalid signature 000004 invalid recvWindow 000005 invalid timestamp. timestamp for this request is outside of the recvWindow. Or timestamp for this request was 1000ms ahead of the server's time. 000006 invalid argument All time and timestamp related fields are in millisecond.
HTTP 5XX return codes are used for internal errors. The issue is on partner's side. Binance will NOT treat this as a failure operation; the execution status is UNKNOWN.
For GET endpoints, parameters must be sent as a query string.
For POST, PUT , and DELETE endpoints, the parameters must be sent in the request body with content type application/x-www-form-urlencoded.
Parameters may be sent in any order.
Requests out of receiving window must NOT be executed. Partner's server should verify:
- recvWindow <= 10000 (ms)
- partner's server time - 3000 < timestamp < partner's server time + recvWindow.
Every partner need to define a url prefix so that Binance can invoke the partner's endpoint using prefix + endpoint_url.
Each request and response should be logged in both Binance and partner's sides for further investigation.
#
Signature- In order to ensure the data security, all SIGNED endpoints should be signed by Binance and be verified by partners. We would use RSA encrption/signature to do the signature.
- Binance will generate a private public key pair for each partner and send each partner their public key via email.
- When Binance invokes a partner's SIGNED endpoint, Binance will send "timestamp", "recvWindow" in the url (GET) or request body (POST, PUT and DELETE) and "signature" in header (GET, POST, PUT and DELETE).
- Partners should verify the signature of all paratemeters in the url , including timestamp and recvWindow, is correct by the public key. Example:
RSAUtil
#
API Specification#
Server Time (UNSIGNED)Parameters: None
Response Body:
Name | Type | Mandatory | Description |
---|---|---|---|
code | String | YES | "000000" |
message | String | YES | "success" |
data | Long | YES | timestamp |
Response examples:
#
Task Completion (SIGNED)Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
walletAddress | String | YES | a user's unifed id |
task | String json array | YES | task names. "deposit", "withdraw". if it's not empty, just return specific task completion status. otherwise, return all tasks completion statuses. |
recvWindow | Long | YES | received window |
timestamp | Long | YES | client timestamp of the request |
Headers:
Name | Type | Mandatory | Description |
---|---|---|---|
signature | String | YES | signature of the request |
Response Body:
Name | Type | Mandatory | Description |
---|---|---|---|
code | String | YES | |
message | String | YES | |
data | JSON Object | YES | timestamp |
data:
Name | Type | Mandatory | Description |
---|---|---|---|
walletAddress | String | YES | a user's unifed id |
task | String json array | YES | task names. "deposit", "withdrawal" |
recvWindow | Long | YES | received window |
timestamp | Long | YES | client timestamp of the request |
examples: