1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use crate::{
clients::spot::BnSpot,
common::response::{BnRestRespType, BnWsApiRespType},
data::{
enums::ratelimit::BnRateLimitType, exchange_information::BnSpotExchangeInformation,
server_time::BnServerTime,
},
};
use http::Method;
use nonzero_ext::nonzero;
use xapi_shared::{data::empty::SharedEmpty, rest::SharedRestClientTrait};
impl BnSpot {
/// Test connectivity to the Rest API.
///
/// <https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#test-connectivity>
pub async fn ping(&self) -> BnRestRespType<SharedEmpty> {
self.executor
.call_with_no_payload(
&[
(BnRateLimitType::RequestWeight, nonzero!(1u32)),
(BnRateLimitType::RawRequests, nonzero!(1u32)),
],
false,
Method::GET,
self.executor
.get_endpoint()
.build_rest_api_url("/api/v3/ping"),
)
.await
}
/// Test connectivity to the WebSocket API.
///
/// <https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/general-requests#test-connectivity>
pub async fn ping_ws(&self) -> BnWsApiRespType<SharedEmpty> {
self.executor
.call_ws_api(
&[
(BnRateLimitType::RequestWeight, nonzero!(1u32)),
(BnRateLimitType::RawRequests, nonzero!(1u32)),
],
false,
"ping",
None::<()>,
)
.await
}
/// Test connectivity to the Rest API and get the current server time.
///
/// <https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#check-server-time>
pub async fn get_server_time(&self) -> BnRestRespType<BnServerTime> {
self.executor
.call_with_no_payload(
&[
(BnRateLimitType::RequestWeight, nonzero!(1u32)),
(BnRateLimitType::RawRequests, nonzero!(1u32)),
],
false,
Method::GET,
self.executor
.get_endpoint()
.build_rest_api_url("/api/v3/time"),
)
.await
}
/// Test connectivity to the WebSocket API and get the current server time.
///
/// <https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/general-requests#check-server-time>
pub async fn get_server_time_ws(&self) -> BnWsApiRespType<BnServerTime> {
self.executor
.call_ws_api(
&[
(BnRateLimitType::RequestWeight, nonzero!(1u32)),
(BnRateLimitType::RawRequests, nonzero!(1u32)),
],
false,
"time",
None::<()>,
)
.await
}
/// Current exchange trading rules and symbol information
///
/// <https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#exchange-information>
pub async fn get_exchange_information(&self) -> BnRestRespType<BnSpotExchangeInformation> {
self.executor
.call_with_no_payload(
&[
(BnRateLimitType::RequestWeight, nonzero!(20u32)),
(BnRateLimitType::RawRequests, nonzero!(1u32)),
],
false,
Method::GET,
self.executor
.get_endpoint()
.build_rest_api_url("/api/v3/exchangeInfo"),
)
.await
}
/// Query current exchange trading rules, rate limits, and symbol information.
///
/// <https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/general-requests#exchange-information>
pub async fn get_exchange_information_ws(&self) -> BnWsApiRespType<BnSpotExchangeInformation> {
self.executor
.call_ws_api(
&[
(BnRateLimitType::RequestWeight, nonzero!(20u32)),
(BnRateLimitType::RawRequests, nonzero!(1u32)),
],
false,
"exchangeInfo",
None::<()>,
)
.await
}
}