BINANCE API
Tích hợp giao dịch Binance
Đồng bộ lịch sử giao dịch Binance vào hệ thống quản lý bằng API token. Kết nối này phù hợp cho nền tảng tài sản số và hệ thống theo dõi giao dịch nội bộ.
Phương thứcGET
Định dạngJSON
Xác thựcToken
Phiên bảnV1, V2
Tài liệu API theo phiên bản
Chọn phiên bản tương ứng trong trang quản lý tài khoản Binance để xem tham số và dữ liệu trả về.
Tham số cần thiết
| Tham số | Bắt buộc | Mô tả |
|---|---|---|
YOUR_TOKEN | Có | Token API được cấp trong trang quản lý. |
Code mẫu
curl --request GET \
"https://thueapibank.vn/historyapibinance/YOUR_TOKEN" \
--header "Accept: application/json"
<?php
$ch = curl_init('https://thueapibank.vn/historyapibinance/YOUR_TOKEN');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 20,
CURLOPT_HTTPHEADER => ['Accept: application/json'],
]);
$response = curl_exec($ch);
$data = json_decode($response, true, flags: JSON_THROW_ON_ERROR);
curl_close($ch);
const response = await fetch('https://thueapibank.vn/historyapibinance/YOUR_TOKEN', {
headers: { Accept: 'application/json' }
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
Response mẫu
{
"rows": [
{
"timestamp": 1772890971000,
"asset": "USDT",
"amount": "0.198082",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 354682953188
},
{
"timestamp": 1772890948000,
"asset": "USDT",
"amount": "25.948742",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 354682962883
},
{
"uid": 10967669,
"counterpartyId": 962409864,
"orderId": "418846039925301248",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1ZF6S1PC4171113",
"transactionTime": 1772877186890,
"amount": "-1",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDT",
"amount": "1",
"walletAssetCost": {
"2": "1"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "user-1761",
"type": "USER",
"binanceId": 962441761,
"accountId": 962409864,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1772877186890,
"type": "BINANCE_PAY"
},
{
"timestamp": 1772807312000,
"asset": "USDT",
"amount": "0.0059",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 354522498324
},
{
"timestamp": 1772807179000,
"asset": "USDT",
"amount": "40.0436152",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 354522496900
},
{
"timestamp": 1772447832000,
"asset": "USDT",
"amount": "56.9455536",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 353557137889
},
{
"timestamp": 1772376506000,
"asset": "USDT",
"amount": "100.07",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 353426886392
},
{
"timestamp": 1772295337000,
"asset": "BTC",
"amount": "0.00022372",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 353240647010
},
{
"timestamp": 1772288820000,
"asset": "USDT",
"amount": "37.59821",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 353208227589
},
{
"timestamp": 1771879833000,
"asset": "USDT",
"amount": "11.5728642",
"type": "FUNDING_MAIN",
"status": "CONFIRMED",
"tranId": 352201713075
},
{
"uid": 10967669,
"counterpartyId": 962409864,
"orderId": "416451146939777024",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1Z6PGFEUD571113",
"transactionTime": 1771761977160,
"amount": "-5",
"currency": "USDT",
"walletType": 1,
"walletTypes": [
"1"
],
"fundsDetail": [
{
"currency": "USDT",
"amount": "5",
"walletAssetCost": {
"1": "5"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "user-1761",
"type": "USER",
"binanceId": 962441761,
"accountId": 962409864,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1771761977160,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 962409864,
"orderId": "415919180570738688",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1Z4T1692FS71112",
"transactionTime": 1771514261353,
"amount": "-2",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDT",
"amount": "2",
"walletAssetCost": {
"2": "2"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "user-1761",
"type": "USER",
"binanceId": 962441761,
"accountId": 962409864,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1771514261353,
"type": "BINANCE_PAY"
},
{
"timestamp": 1770653798000,
"asset": "USDT",
"amount": "1091.99",
"type": "MAIN_FUNDING",
"status": "CONFIRMED",
"tranId": 349385484082
},
{
"uid": 10967669,
"counterpartyId": 962409864,
"orderId": "412217563038040064",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1YQN6S9V9571116",
"transactionTime": 1769790561793,
"amount": "-20",
"currency": "USDT",
"walletType": 5,
"walletTypes": [
"5"
],
"fundsDetail": [
{
"currency": "USDT",
"amount": "20",
"walletAssetCost": {
"5": "20"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "user-1761",
"type": "USER",
"binanceId": 962441761,
"accountId": 962409864,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1769790561793,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 256666211,
"orderId": "411431738618953728",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1YMUUYA97H71113",
"transactionTime": 1769424633578,
"amount": "-20",
"currency": "USDT",
"walletType": 5,
"walletTypes": [
"5"
],
"fundsDetail": [
{
"currency": "USDT",
"amount": "20",
"walletAssetCost": {
"5": "20"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "User-28a63",
"type": "USER",
"binanceId": 112984866,
"accountId": 256666211,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1769424633578,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 241961148,
"orderId": "409737601667301376",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1YEU8QSM7971117",
"transactionTime": 1768635739741,
"amount": "-20",
"currency": "USDT",
"walletType": 5,
"walletTypes": [
"5"
],
"fundsDetail": [
{
"currency": "USDT",
"amount": "20",
"walletAssetCost": {
"5": "20"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "Isobel Ko Pz1q",
"type": "USER",
"binanceId": 78850743,
"accountId": 241961148,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1768635739741,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 990846129,
"orderId": "409039504021954560",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1YCBW2J65D7111H",
"transactionTime": 1768310662503,
"amount": "-20",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "20.05737339",
"walletAssetCost": {
"2": "20.05737339"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "up57bb",
"type": "USER",
"binanceId": 990793548,
"accountId": 990846129,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1768310662503,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 241961148,
"orderId": "407890703693701120",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1Y899RP4BS7111G",
"transactionTime": 1767775710716,
"amount": "-20",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "20.06740418",
"walletAssetCost": {
"2": "20.06740418"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "Isobel Ko Pz1q",
"type": "USER",
"binanceId": 78850743,
"accountId": 241961148,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1767775710716,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 962409864,
"orderId": "406695785733980160",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1Y41ENXFSW71112",
"transactionTime": 1767219283822,
"amount": "-10",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "10.03470577",
"walletAssetCost": {
"2": "10.03470577"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "user-1761",
"type": "USER",
"binanceId": 962441761,
"accountId": 962409864,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1767219283822,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 962409864,
"orderId": "406048493411237888",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1Y1QUU67JD71119",
"transactionTime": 1766917864880,
"amount": "-5",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "5.01936126",
"walletAssetCost": {
"2": "5.01936126"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "user-1761",
"type": "USER",
"binanceId": 962441761,
"accountId": 962409864,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1766917864880,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 990846129,
"orderId": "405119678835605504",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XXE8U631171115",
"transactionTime": 1766485352100,
"amount": "-20",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "20.07945438",
"walletAssetCost": {
"2": "20.07945438"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "up57bb",
"type": "USER",
"binanceId": 990793548,
"accountId": 990846129,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1766485352100,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 990846129,
"orderId": "404746767993626624",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XW3V69XES71118",
"transactionTime": 1766311701499,
"amount": "-10",
"currency": "USDT",
"walletType": 5,
"walletTypes": [
"5"
],
"fundsDetail": [
{
"currency": "USDT",
"amount": "10",
"walletAssetCost": {
"5": "10"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "up57bb",
"type": "USER",
"binanceId": 990793548,
"accountId": 990846129,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1766311701499,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 990846129,
"orderId": "403804916021903360",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XSRSRAJU571117",
"transactionTime": 1765873117621,
"amount": "-20",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "20.07744504",
"walletAssetCost": {
"2": "20.07744504"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "up57bb",
"type": "USER",
"binanceId": 990793548,
"accountId": 990846129,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1765873117621,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 990846129,
"orderId": "403650799862185984",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XS792UKTH7111C",
"transactionTime": 1765801351646,
"amount": "-20",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "20.07744501",
"walletAssetCost": {
"2": "20.07744501"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "up57bb",
"type": "USER",
"binanceId": 990793548,
"accountId": 990846129,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1765801351646,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 241961148,
"orderId": "403650673160650752",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XS78M3VT971115",
"transactionTime": 1765801292329,
"amount": "-20",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "20.07744501",
"walletAssetCost": {
"2": "20.07744501"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "Isobel Ko Pz1q",
"type": "USER",
"binanceId": 78850743,
"accountId": 241961148,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1765801292329,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 990846129,
"orderId": "403629443035021312",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XS4UCHATN71119",
"transactionTime": 1765791406263,
"amount": "-20",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "20.07945438",
"walletAssetCost": {
"2": "20.07945438"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "up57bb",
"type": "USER",
"binanceId": 990793548,
"accountId": 990846129,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1765791406263,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 246062661,
"orderId": "402594832943554560",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XNF7GDMKW71112",
"transactionTime": 1765309629104,
"amount": "-3",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "3.01191816",
"walletAssetCost": {
"2": "3.01191816"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "HMSocialMedia_Panel",
"type": "USER",
"binanceId": 91699988,
"accountId": 246062661,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1765309629104,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 241961148,
"orderId": "402529409637302272",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XN7SFV7BN71117",
"transactionTime": 1765279163548,
"amount": "-10",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "10.03972719",
"walletAssetCost": {
"2": "10.03972719"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "Isobel Ko Pz1q",
"type": "USER",
"binanceId": 78850743,
"accountId": 241961148,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1765279163548,
"type": "BINANCE_PAY"
},
{
"uid": 10967669,
"counterpartyId": 246062661,
"orderId": "402513943586799616",
"note": "",
"orderType": "C2C",
"transactionId": "P_A1XN617DMKW71116",
"transactionTime": 1765271961908,
"amount": "-1.01",
"currency": "USDT",
"walletType": 2,
"walletTypes": [
"2"
],
"fundsDetail": [
{
"currency": "USDE",
"amount": "1.01391098",
"walletAssetCost": {
"2": "1.01391098"
}
}
],
"payerInfo": {
"binanceId": 10967669,
"unmaskData": false
},
"receiverInfo": {
"name": "HMSocialMedia_Panel",
"type": "USER",
"binanceId": 91699988,
"accountId": 246062661,
"unmaskData": true,
"extend": {
"phoneOrEmailChanged": false
}
},
"totalPaymentFee": "0",
"timestamp": 1765271961908,
"type": "BINANCE_PAY"
}
]
}
Tham số cần thiết
| Tham số | Bắt buộc | Mô tả |
|---|---|---|
YOUR_TOKEN | Có | Token API được cấp trong trang quản lý. |
Code mẫu
curl --request GET \
"https://thueapibank.vn/historyapibinancev2/YOUR_TOKEN" \
--header "Accept: application/json"
<?php
$ch = curl_init('https://thueapibank.vn/historyapibinancev2/YOUR_TOKEN');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 20,
CURLOPT_HTTPHEADER => ['Accept: application/json'],
]);
$response = curl_exec($ch);
$data = json_decode($response, true, flags: JSON_THROW_ON_ERROR);
curl_close($ch);
const response = await fetch('https://thueapibank.vn/historyapibinancev2/YOUR_TOKEN', {
headers: { Accept: 'application/json' }
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
Response mẫu
{
"status": "success",
"message": "Thành công",
"transactions": [
{
"type": "IN",
"transactionID": "FT26091912345678",
"amount": 450000,
"description": "DH1024 THANH TOAN",
"transactionDate": "2026-09-19 10:24:36"
}
]
}
Response thực tế có thể bổ sung trường riêng của Binance. Luôn kiểm tra trường tồn tại trước khi đọc.
Luồng xử lý khuyến nghị
- 1Lưu mã giao dịch
Dùng
transactionIDlàm khóa chống xử lý trùng. - 2Chỉ xử lý tiền vào
Kiểm tra
type === "IN"trước khi ghép đơn. - 3Ghép đúng đơn hàng
So khớp số tiền và mã đơn trong nội dung chuyển khoản.
- 4Đối soát lại
Chạy tác vụ định kỳ để bù các webhook bị chậm hoặc thất bại.
Câu hỏi về API Binance
API Binance dùng để làm gì?
API giúp lấy dữ liệu giao dịch Binance dạng JSON để xác nhận chuyển khoản, cộng số dư và đối soát tự động.
Nên dùng phiên bản API nào?
Nên ưu tiên phiên bản mới nhất mà tài khoản của bạn đang hỗ trợ. V1 và V2 phù hợp tích hợp bằng token; V3 bổ sung thông tin tài khoản trong đường dẫn.
Có thể nhận giao dịch Binance qua webhook không?
Có. Sau khi thêm tài khoản, bạn có thể cấu hình URL webhook để hệ thống gửi sự kiện giao dịch mới về máy chủ của bạn.