crypto_rest_client/exchanges/bitget/
bitget_spot.rs

1use super::super::utils::http_get;
2use crate::error::Result;
3use std::collections::BTreeMap;
4
5const BASE_URL: &str = "https://api.bitget.com";
6
7/// The RESTful client for Bitget spot market.
8///
9/// * RESTful API doc: <https://bitgetlimited.github.io/apidoc/en/spot/>
10/// * Trading at: <https://www.bitget.com/spot/>
11pub struct BitgetSpotRestClient {
12    _api_key: Option<String>,
13    _api_secret: Option<String>,
14}
15
16impl BitgetSpotRestClient {
17    pub fn new(api_key: Option<String>, api_secret: Option<String>) -> Self {
18        BitgetSpotRestClient { _api_key: api_key, _api_secret: api_secret }
19    }
20
21    /// Get the latest Level2 snapshot of orderbook.
22    ///
23    /// Top 150 bids and asks are returned.
24    ///
25    /// For example: <https://api.bitget.com/api/spot/v1/market/depth?symbol=BTCUSDT_SPBL&type=step0>,
26    pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
27        gen_api!(format!("/api/spot/v1/market/depth?symbol={symbol}&type=step0"))
28    }
29}