datamaxi/lib.rs
1//! # DataMaxi+ Rust SDK
2//!
3//! This is the official implementation of Rust SDK for [DataMaxi+](https://datamaxiplus.com/).
4//! The package can be used to fetch both historical and latest data using [DataMaxi+ API](https://docs.datamaxiplus.com/).
5//!
6//! - [Installation](#installation)
7//! - [Configuration](#configuration)
8//! - [Links](#links)
9//! - [Contributing](#contributing)
10//! - [License](#license)
11//!
12//! ## Installation
13//!
14//! ```shell
15//! [dependencies]
16//! datamaxi = { git = "https://github.com/bisonai/datamaxi-rust.git" }
17//! ```
18//!
19//! ## Configuration
20//!
21//! Private API endpoints are protected by an API key.
22//! You can get the API key upon registering at <https://datamaxiplus.com/auth>.
23//!
24//!
25//!| Option | Explanation |
26//!|------------|-------------------------------------------------------------------------------|
27//!| `api_key` | Your API key |
28//!| `base_url` | If `base_url` is not provided, it defaults to `https://api.datamaxiplus.com`. |
29//!
30//! ## Examples
31//!
32//! ### CEX Candle
33//!
34//! ```rust
35//! let api_key = "my_api_key".to_string();
36//! let candle: datamaxi::cex::Candle = datamaxi::api::Datamaxi::new(api_key);
37//!
38//! // Fetch supported exchanges for CEX candle data
39//! candle.exchanges("spot");
40//!
41//! // Fetch supported symbols for CEX candle data
42//! let symbols_options = datamaxi::cex::SymbolsOptions::new();
43//! candle.symbols("binance", symbols_options);
44//!
45//! // Fetch supported intervals for CEX candle data
46//! candle.intervals();
47//!
48//! // Fetch CEX candle data
49//! let candle_options = datamaxi::cex::CandleOptions::new();
50//! candle.get("binance", "ETH-USDT", candle_options);
51//! ```
52//!
53//! ### DEX
54//!
55//! ```rust
56//! let api_key = "my_api_key".to_string();
57//! let dex: datamaxi::dex::Dex = datamaxi::api::Datamaxi::new(api_key);
58//!
59//! // Fetch supported intervals for DEX candle data
60//! dex.intervals();
61//!
62//! // Fetch supported exchange for DEX data
63//! dex.exchanges();
64//!
65//! // Fetch supported chains for DEX data
66//! dex.chains();
67//!
68//! // Fetch supported pools for DEX data
69//! let pools_options = datamaxi::dex::PoolsOptions::new();
70//! dex.pools(pools_options);
71//!
72//! // Fetch DEX candle data
73//! let params = datamaxi::dex::CandleOptions::new();
74//! dex.candle(
75//! "bsc_mainnet",
76//! "pancakeswap",
77//! "0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423",
78//! params,
79//! );
80//!
81//! // Fetch DEX trade data
82//! let trade_options = datamaxi::dex::TradeOptions::new().limit(5);
83//! dex.trade(
84//! "bsc_mainnet",
85//! "pancakeswap",
86//! "0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423",
87//! trade_options
88//! );
89//! ```
90//!
91//! ## Links
92//!
93//! - [Official Website](https://datamaxiplus.com/)
94//! - [Documentation](https://docs.datamaxiplus.com/)
95//!
96//! ## Contributing
97//!
98//! We welcome contributions!
99//! If you discover a bug in this project, please feel free to open an issue to discuss the changes you would like to propose.
100//!
101//! ## License
102//!
103//
104
105/// API definitions and related utilities.
106pub mod api;
107
108/// CEX-related data fetcher and data structures.
109///
110/// This module provides functionality related to centralized exchange (CEX) data.
111/// It includes data structures and methods for retrieving candle data, as well as information about supported exchanges, symbols and intervals.
112///
113/// # Usage
114///
115/// The `Candle` struct is the primary interface for interacting with the CEX data.
116/// It provides methods for retrieving data with optional parameters to filter and sort the results.
117///
118/// ## Example
119///
120/// ```rust
121/// let config = datamaxi::api::Config {
122/// base_url: None,
123/// api_key: "my_api_key".to_string(),
124/// };
125/// let client = datamaxi::api::Client::new(config);
126/// let candle = datamaxi::cex::Candle { client: client.clone() };
127///
128/// // Retrieve supported exchanges
129/// let exchanges = candle.exchanges("spot");
130///
131/// // Retrieve supported intervals
132/// let intervals = candle.intervals();
133///
134/// // Retrieve supported Binance symbols
135/// let symbols_options = datamaxi::cex::SymbolsOptions::new();
136/// let symbols = candle.symbols("binance", symbols_options);
137///
138/// // Retrieve candle data
139/// let candle_options = datamaxi::cex::CandleOptions::new().interval("1h").market("spot");
140/// let candle_data = candle.get("binance", "BTC-USDT", candle_options);
141/// ```
142///
143/// # Error Handling
144///
145/// All methods return a `Result` type, which should be handled appropriately to manage potential errors.
146pub mod cex;
147
148/// DEX-related data fetcher and data structures.
149///
150/// This module provides functionality related to decentralized exchange (DEX) data,
151/// It includes data structures and methods for retrieving candle and trade data, as well as information supported chains, exchanges, pools and intervals.
152///
153/// # Usage
154///
155/// The `Candle` and `Trade` structs are the primary interfaces for interacting with the DEX data.
156/// They provide methods for retrieving data with optional parameters to filter and sort the results.
157///
158/// ## Example
159///
160/// ```rust
161/// let config = datamaxi::api::Config {
162/// base_url: None,
163/// api_key: "my_api_key".to_string(),
164/// };
165/// let client = datamaxi::api::Client::new(config);
166/// let dex = datamaxi::dex::Dex { client: client.clone() };
167///
168/// // Retrieve candle data
169/// let candle_options = datamaxi::dex::CandleOptions::new().interval("1h").limit(100);
170/// let candle_data = dex.candle("kaia_mainnet", "dragonswap", "0x...", candle_options);
171///
172/// // Retrieve trade data
173/// let trade_options = datamaxi::dex::TradeOptions::new().limit(50);
174/// let trade_data = dex.trade("kaia_mainnet", "dragonswap", "0x...", trade_options);
175///
176/// // Retrieve available pools
177/// let pools_options = datamaxi::dex::PoolsOptions::new().chain("kaia_mainnet");
178/// let pools = dex.pools(pools_options);
179/// ```
180///
181/// # Error Handling
182///
183/// All methods return a `Result` type, which should be handled appropriately to manage potential errors.
184pub mod dex;
185
186/// Data models representing API responses and optional parameters.
187pub mod models;
188
189/// Auto-generated typed wrappers for every public REST endpoint on
190/// the data API. This module is the canonical surface for the OI /
191/// Liquidation / cex-symbol surfaces; the older hand-written modules
192/// (`cex`, `dex`) cover only a subset of endpoints and are kept for
193/// backward compatibility.
194///
195/// Usage:
196/// ```ignore
197/// use datamaxi::api::Datamaxi;
198/// use datamaxi::generated::{Liquidation, LiquidationHeatmapOptions};
199///
200/// let liq: Liquidation = Datamaxi::new("YOUR_API_KEY".into());
201/// let opts = LiquidationHeatmapOptions::new();
202/// let heatmap = liq.heatmap(opts)?;
203/// ```
204pub mod generated;