> For the complete documentation index, see [llms.txt](https://support.backpack.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.backpack.exchange/support-docs/vn/san-giao-dich/api-and-tai-lieu-danh-cho-nha-phat-trien/faqs.md).

# FAQs

<details>

<summary>Backpack hỗ trợ những API nào?</summary>

Backpack cung cấp hai cách tích hợp, tùy thuộc vào việc bạn cần các thao tác request/response hay dữ liệu streaming theo thời gian thực.

#### REST API

Sử dụng REST API cho các thao tác theo yêu cầu như lấy dữ liệu thị trường/tài khoản và quản lý lệnh.

Các endpoint phổ biến bao gồm:

* GET /markets
* GET /balances
* POST /orders
* DELETE /orders

#### WebSocket API

Sử dụng WebSocket API cho các luồng thời gian thực có độ trễ thấp.

Các trường hợp sử dụng phổ biến bao gồm:

* Đăng ký cập nhật sổ lệnh (order book)
* Đăng ký luồng nến (kline)
* Đăng ký các sự kiện tài khoản được xác thực (ví dụ: cập nhật lệnh và vị thế)

</details>

<details>

<summary>API có thể dùng để giao dịch hợp đồng tương lai không?</summary>

Có. Backpack hỗ trợ cả spot và perpetual futures thông qua cùng một endpoint lệnh và tài khoản. Để giao dịch perp, hãy sử dụng ký hiệu thị trường perp.

Ví dụ: POST /orders - SOL\_USDC\_PERP

</details>

<details>

<summary>Tôi có thể rút tài sản bằng API không?</summary>

Để bật rút tiền, cần có các biện pháp kiểm soát bảo mật nghiêm ngặt (bao gồm xác thực hai yếu tố).

Để cấu hình địa chỉ rút tiền với 2FA bắt buộc, **vui lòng sử dụng:**\
<https://backpack.exchange/settings/withdrawal-addresses?twoFactorWithdrawalAddress=true>

**Tham số twoFactorToken** (<https://docs.backpack.exchange/#tag/Capital/operation/request\\_withdrawal:\\~:text=asset%20to%20withdraw.-,twoFactorToken,-string>) hiện đang bị vô hiệu hóa

</details>

<details>

<summary>Giới hạn tốc độ API là gì? Chúng khác nhau theo server hay theo subaccount?</summary>

Giới hạn tốc độ được áp dụng theo subaccount, không phải theo server. Theo mặc định, mỗi subaccount có thể thực hiện tối đa 2000 request mỗi phút trên các REST endpoint tiêu chuẩn.

Các endpoint dữ liệu thị trường lịch sử bị giới hạn ở mức 30 request mỗi phút mỗi subaccount. ("Endpoint lịch sử" đề cập đến các REST route trả về dữ liệu theo khoảng thời gian như candles/trades.)

Nếu bạn chạm giới hạn, bạn sẽ nhận được phản hồi HTTP 429. Hãy cân nhắc sử dụng WebSocket streams cho dữ liệu thị trường tần suất cao.

</details>

<details>

<summary>Các lỗi phổ biến khi đặt lệnh là gì?</summary>

<table data-header-hidden><thead><tr><th width="256.142333984375"></th><th></th><th></th></tr></thead><tbody><tr><td>Error Code</td><td>Mô tả</td><td>Cách xử lý</td></tr><tr><td>INVALID_CLIENT_REQUEST'</td><td>Invalid signature / Chữ ký không hợp lệ</td><td>Xác minh phương thức tạo query string (sorting, instruction, value). Đồng thời kiểm tra các giá trị boolean trong query string phải viết thường. "True" phải là "true".</td></tr><tr><td>INVALID_CLIENT_REQUEST'</td><td>Request has expired / Yêu cầu đã hết hạn</td><td>Thời gian request đến máy chủ sàn vượt quá giá trị X-Window. Hãy thử tăng giá trị window.</td></tr><tr><td>INVALID_CLIENT_REQUEST'</td><td>Quantity decimal too long / Số thập phân của số lượng quá dài</td><td>Điều chỉnh số lượng theo stepSize.</td></tr><tr><td>INVALID_CLIENT_REQUEST'</td><td>Invalid X-Signature Header / Header X-Signature không hợp lệ</td><td>Query string được ký bằng sai keypair. Xác minh rằng bạn đang sử dụng ED25519.</td></tr><tr><td>429</td><td>Too many requests / Quá nhiều yêu cầu</td><td>Giảm tần suất request; cân nhắc sử dụng WebSocket streaming.</td></tr></tbody></table>

</details>

<details>

<summary>Tôi có thể tìm SDK ở đâu?</summary>

SDK chính thức hiện chỉ có bằng Rust: <https://github.com/backpack-exchange/bpx-api-client>\
\
Vui lòng tham khảo trang sau để xem các ví dụ do cộng đồng duy trì bằng nhiều ngôn ngữ khác nhau:\
<https://support.backpack.exchange/exchange/api-and-developer-docs/api-clients>

</details>

<details>

<summary>Làm thế nào để lấy dữ liệu thị trường theo thời gian thực cho một cặp giao dịch?</summary>

Sử dụng WebSocket streams để cập nhật thị trường trực tiếp:

[Book Ticker](https://docs.backpack.exchange/#tag/Streams/Public/Book-ticker) (bookTicker.\<symbol>)\
Giá bid/ask tốt nhất và số lượng theo thời gian thực. Lý tưởng cho hiển thị top-of-book.

[Depth](https://docs.backpack.exchange/#tag/Streams/Public/Depth) (depth.\<symbol>)\
Cập nhật order book theo từng bước. Bắt đầu bằng cách lấy snapshot ban đầu qua REST, sau đó áp dụng các depth delta từ stream. Depth có thể dùng ở chế độ thời gian thực hoặc tổng hợp (ví dụ: 200ms / 600ms / 1000ms) để giảm lưu lượng.\
\
Xem danh sách đầy đủ các stream tại đây: [https://docs.backpack.exchange/#tag/Streams](https://docs.backpack.exchange/#tag/Streamshttps://docs.backpack.exchange/#tag/Streams)

</details>

<details>

<summary>Làm thế nào để cải thiện độ ổn định của trading bot?</summary>

Các best practice được khuyến nghị:

* Ưu tiên WebSocket subscriptions cho cập nhật lệnh/giao dịch thời gian thực thay vì polling REST
* Áp dụng retry + exponential backoff cho các request REST và kết nối lại WS
* Lưu cache local cho các dữ liệu tham chiếu thường dùng (markets, symbols, filters) và làm mới định kỳ
* Theo dõi và cảnh báo các lỗi API quan trọng (lỗi xác thực, request hết hạn, và rate limit 429)

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://support.backpack.exchange/support-docs/vn/san-giao-dich/api-and-tai-lieu-danh-cho-nha-phat-trien/faqs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
