API Tài khoản ngân hàng

API tài khoản ngân hàng giúp lấy danh sách các tài khoản ngân hàng đã được thêm vào SePay. Truy vấn thông tin chi tiết từng tài khoản, số dư từng tài khoản.


Bạn có thể làm gì với API này?

SePay cho phép bạn thực hiện những truy vấn sau với Tài khoản ngân hàng:

GET
https://my.sepay.vn/userapi/bankaccounts/list
  • Lấy danh sách các tài khoản ngân hàng
GET
https://my.sepay.vn/userapi/bankaccounts/details/{bank_account_id}
  • Lấy chi tiết một tài khoản ngân hàng
GET
https://my.sepay.vn/userapi/bankaccounts/count
  • Đếm số lượng tài khoản ngân hàng

Lấy danh sách tài khoản ngân hàng

GET
https://my.sepay.vn/userapi/bankaccounts/list

Lấy tất cả tài khoản ngân hàng. Mặc định chỉ hiển thị 100 tài khoản ngân hàng được thêm gần nhất.

Tham số truy vấn
statusinteger

Mã HTTP status

errorstring

Thông báo lỗi (null nếu thành công)

messagesobject
bankaccountsarray<object>
Thông tin

Xem tên ngân hàng, tương ứng với trường short_name tại đây

Code mẫu
>
>
>
curl --request GET \
--url 'https://my.sepay.vn/userapi/bankaccounts/list?short_name=Vietcombank&last_transaction_date_min=2023-04-30&last_transaction_date_max=2023-05-02&since_id=20&limit=20&accumulated_min=1&accumulated_max=1000000000' \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
Response
Response 200 - Danh sách tài khoản ngân hàng
{
  "status": 200,
  "error": null,
  "messages": {
    "success": true
  },
  "bankaccounts": [
    {
      "id": "25",
      "account_holder_name": "NGUYEN THI B",
      "account_number": "102871015203",
      "accumulated": "2525493.00",
      "last_transaction": "2023-02-16 16:16:00",
      "label": "",
      "active": "1",
      "created_at": "2023-02-16 15:57:26",
      "bank_short_name": "VietinBank",
      "bank_full_name": "Ngân hàng TMCP Công Thương Việt Nam",
      "bank_bin": "970415",
      "bank_code": "ICB"
    }
  ]
}
statusinteger

Mã HTTP status

errorstring

Thông báo lỗi (null nếu thành công)

messagesobject
bankaccountsarray<object>
Ví dụ sử dụng

Lấy tài khoản ngân hàng có giao dịch sau 08h00 ngày 30/04/2023 và trước 12h00 ngày 02/05/2023

JScURL
1
2
3
curl -X GET "https://my.sepay.vn/userapi/bankaccounts/list?last_transaction_date_min=2023-04-30%2008:00:00&last_transaction_date_max=2023-05-02%2012:00:00" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN"

Lấy tài khoản ngân hàng từ ID 20 trở về sau

JScURL
1
2
3
curl -X GET "https://my.sepay.vn/userapi/bankaccounts/list?since_id=20" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN"

Lấy 20 tài khoản của ngân hàng Vietcombank

JScURL
1
2
3
curl -X GET "https://my.sepay.vn/userapi/bankaccounts/list?short_name=Vietcombank&limit=20" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN"

Lọc tài khoản ngân hàng có số dư >= 1 VND

JScURL
1
2
3
curl -X GET "https://my.sepay.vn/userapi/bankaccounts/list?accumulated_min=1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN"

Lấy chi tiết một tài khoản ngân hàng

GET
https://my.sepay.vn/userapi/bankaccounts/details/{bank_account_id}

Lấy thông tin chi tiết một tài khoản ngân hàng theo ID.

Tham số đường dẫn
statusinteger

Mã HTTP status

errorstring

Thông báo lỗi (null nếu thành công)

messagesobject
bankaccountobject
Code mẫu
>
>
>
curl --request GET \
--url https://my.sepay.vn/userapi/bankaccounts/details/18 \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
Response
Response 200 - Chi tiết tài khoản ngân hàng
{
  "status": 200,
  "error": null,
  "messages": {
    "success": true
  },
  "bankaccount": {
    "id": "18",
    "account_holder_name": "NGUYEN VAN A",
    "account_number": "0071000899999",
    "accumulated": "2625076186.00",
    "last_transaction": "2023-08-09 07:59:48",
    "label": "",
    "active": "1",
    "created_at": "2023-02-12 20:05:47",
    "bank_short_name": "Vietcombank",
    "bank_full_name": "Ngân hàng TMCP Ngoại Thương Việt Nam",
    "bank_bin": "970436",
    "bank_code": "VCB"
  }
}
statusinteger

Mã HTTP status

errorstring

Thông báo lỗi (null nếu thành công)

messagesobject
bankaccountobject

Đếm số lượng tài khoản ngân hàng

GET
https://my.sepay.vn/userapi/bankaccounts/count

Đếm tổng số lượng tài khoản ngân hàng.

Tham số truy vấn
statusinteger

Mã HTTP status

errorstring

Thông báo lỗi (null nếu thành công)

messagesobject
count_bankaccountsinteger

Tổng số tài khoản ngân hàng

Code mẫu
>
>
>
curl --request GET \
--url 'https://my.sepay.vn/userapi/bankaccounts/count?short_name=Vietcombank&last_transaction_date_min=2023-04-30&last_transaction_date_max=2023-05-02&since_id=20&accumulated_min=1&accumulated_max=1000000000' \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
Response
Response 200 - Số lượng tài khoản ngân hàng
{
  "status": 200,
  "error": null,
  "messages": {
    "success": true
  },
  "count_bankaccounts": 9
}
statusinteger

Mã HTTP status

errorstring

Thông báo lỗi (null nếu thành công)

messagesobject
count_bankaccountsinteger

Tổng số tài khoản ngân hàng

Ví dụ sử dụng

Đếm tổng số lượng tài khoản ngân hàng của tài khoản ngân hàng có số dư >=1.

JScURL
1
2
3
curl -X GET "https://my.sepay.vn/userapi/bankaccounts/count?accumulated_min=1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN"

Xử lý lỗi

401Unauthorized

Token không hợp lệ hoặc thiếu.

404Not Found

Không tìm thấy tài khoản ngân hàng.

429Too Many Requests

Vượt quá giới hạn 2 request/giây. Kiểm tra header x-sepay-userapi-retry-after.