crypto_rest_client/exchanges/gate/gate_spot.rs
1use super::super::utils::http_get;
2use crate::error::Result;
3use std::collections::BTreeMap;
4
5const BASE_URL: &str = "https://api.gateio.ws/api/v4";
6
7/// The RESTful client for Gate spot market.
8///
9/// * RESTful API doc: <https://www.gate.io/docs/apiv4/en/index.html>
10/// * Trading at: <https://www.gateio.pro/cn/trade/BTC_USDT>
11/// * Rate Limits: <https://www.gate.io/docs/apiv4/en/index.html#frequency-limit-rule>
12/// * 300 read operations per IP per second
13pub struct GateSpotRestClient {
14 _api_key: Option<String>,
15 _api_secret: Option<String>,
16}
17
18impl GateSpotRestClient {
19 pub fn new(api_key: Option<String>, api_secret: Option<String>) -> Self {
20 GateSpotRestClient { _api_key: api_key, _api_secret: api_secret }
21 }
22
23 /// Get the latest Level2 snapshot of orderbook.
24 ///
25 /// Top 1000 asks and bids are returned.
26 ///
27 /// For example: <https://api.gateio.ws/api/v4/spot/order_book?currency_pair=BTC_USDT&limit=1000>,
28 pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
29 gen_api!(format!("/spot/order_book?currency_pair={symbol}&limit=1000"))
30 }
31}