xapi_binance/clients/spot/
account.rs

1use crate::{
2    clients::spot::BnSpot,
3    common::response::{BnRestRespType, BnWsApiRespType},
4    data::{account_information::BnSpotAccountInformation, enums::ratelimit::BnRateLimitType},
5};
6use http::Method;
7use nonzero_ext::nonzero;
8use xapi_shared::rest::SharedRestClientTrait;
9
10impl BnSpot {
11    /// Get current account information.
12    ///
13    /// <https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data>
14    pub async fn get_account_information(&self) -> BnRestRespType<BnSpotAccountInformation> {
15        self.executor
16            .call_with_no_payload(
17                &[
18                    (BnRateLimitType::RequestWeight, nonzero!(20u32)),
19                    (BnRateLimitType::RawRequests, nonzero!(1u32)),
20                ],
21                true,
22                Method::GET,
23                self.executor
24                    .get_endpoint()
25                    .build_rest_api_url("/api/v3/account"),
26            )
27            .await
28    }
29
30    /// Query information about your account.
31    ///
32    /// <https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/account-requests#account-information-user_data>
33    pub async fn get_account_information_ws(&self) -> BnWsApiRespType<BnSpotAccountInformation> {
34        self.executor
35            .call_ws_api(
36                &[
37                    (BnRateLimitType::RequestWeight, nonzero!(20u32)),
38                    (BnRateLimitType::RawRequests, nonzero!(1u32)),
39                ],
40                true,
41                "account.status",
42                None::<()>,
43            )
44            .await
45    }
46}