Nakoupit kryptoměnu
Zaplatit pomocí
Trhy
NFT
New
Stahování
English
USD

Nejčastější dotazy
Gift Card

Jak vám můžeme pomoci?
Funkce účtu
Výukový kurz pro uživatele
Binance Fan Token
Binance Earn
Vklad/výběr kryptoměn
Koupit kryptoměnu (hotovost/P2P)
Spotové obchody a maržové obchody
Kryptoměnové deriváty
Finance
Kryptoměnové půjčky
Karta Binance
Dárková karta
Binance Pay
API
Zabezpečení
Podmínky použití
NFT
Tento článek není momentálně dostupný ve vašem jazyce. Pro angličtinu se doporučuje automatický překladač.

How to Download and Set up Binance Code API

2022-01-12 08:19
Download API here (Please view in web)
Step 1: Create credential
Register and log in to your Binance account, then go to [API Management]. Enter the label API key and click [Create API].
Upon successful creation, you can get the API Key and Secret Key. Never share your API key or secret key with anyone.
Step 2: Call Binance Code SAPI to generate signature and timestamp
Each API must pass the timestamp and signature parameter, please refer to the Binance official API document.
Each API must add X-MBX-APIKEY: "YOUR_API_KEY" as the request header.
An example of calling Binance Code SAPI via postman:
  • The base endpoint {{sapi_url}} is: https://api.binance.com
  • If there are performance issues with the endpoint above, these API clusters are also available:
    • https://api1.binance.com
    • https://api2.binance.com
    • https://api3.binance.com
You can refer to the following code and copy and paste them to generate the value of {{timestamp}} and {{signature}}.
const ts = Date.now();
pm.environment.set("timestamp", ts);
let paramsObject = {};
const binance_api_secret = "YOUR_API_SECRET";
const parameters = pm.request.url.query;
parameters.map((param) => {
if (param.key != 'signature' &&
param.key != 'timestamp' &&
!is_empty(param.value) &&
!is_disabled(param.disabled)) {
paramsObject[param.key] = param.value;
//console.log(encodeURIComponent(param.value));
//pm.environment.set(param.key encodeURIComponent(param.value));
}
})
Object.assign(paramsObject, {'timestamp': ts});
if (binance_api_secret) {
const queryString = Object.keys(paramsObject).map((key) => {
return `${key}=${paramsObject[key]}`;
}).join('&');
console.log('debug: '+ queryString);
const signature = CryptoJS.HmacSHA256(queryString, binance_api_secret).toString();
console.log(signature)
pm.environment.set("signature", signature);
}
function is_disabled(str) {
return str == true;
}
function is_empty(str) {
if (typeof str == 'undefined' ||
!str ||
str.length === 0 ||
!/[^\\s]/.test(str) ||
/^\\s*$/.test(str))
{
return true;
}
else
{
return false;
}
}