crypto_rest_client/exchanges/bithumb.rs
1use super::utils::http_get;
2use crate::error::Result;
3use std::collections::BTreeMap;
4
5const BASE_URL: &str = "https://global-openapi.bithumb.pro/openapi/v1";
6
7/// The REST client for Bithumb.
8///
9/// Bithumb has only Spot market.
10///
11/// * REST API doc: <https://github.com/bithumb-pro/bithumb.pro-official-api-docs/blob/master/rest-api.md>
12/// * Trading at: <https://en.bithumb.com/trade/order/BTC_KRW>
13/// * Rate Limits: <https://apidocs.bithumb.com/docs/rate_limits>
14/// * 135 requests per 1 second for public APIs.
15/// * 15 requests per 1 second for private APIs.
16pub struct BithumbRestClient {
17 _api_key: Option<String>,
18 _api_secret: Option<String>,
19}
20
21impl BithumbRestClient {
22 pub fn new(api_key: Option<String>, api_secret: Option<String>) -> Self {
23 BithumbRestClient { _api_key: api_key, _api_secret: api_secret }
24 }
25
26 /// Get most recent trades.
27 ///
28 /// For example: <https://global-openapi.bithumb.pro/openapi/v1/spot/trades?symbol=BTC-USDT>
29 pub fn fetch_trades(symbol: &str) -> Result<String> {
30 gen_api!(format!("/spot/trades?symbol={symbol}"))
31 }
32
33 /// Get the latest Level2 orderbook snapshot.
34 ///
35 /// For example: <https://global-openapi.bithumb.pro/openapi/v1/spot/orderBook?symbol=BTC-USDT>
36 pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
37 gen_api!(format!("/spot/orderBook?symbol={symbol}"))
38 }
39}