binance/spot/apis/
market_data_api.rs

1/*
2 * Binance Spot API
3 *
4 * OpenAPI specification for Binance exchange - Spot API
5 *
6 * The version of the OpenAPI document: 0.1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`spot_get_agg_trades_v3`]
18#[derive(Clone, Debug, Default)]
19pub struct SpotGetAggTradesV3Params {
20    pub symbol: String,
21    /// ID to get aggregate trades from INCLUSIVE.
22    pub from_id: Option<i64>,
23    /// Timestamp in ms to get aggregate trades from INCLUSIVE.
24    pub start_time: Option<i64>,
25    /// Timestamp in ms to get aggregate trades until INCLUSIVE.
26    pub end_time: Option<i64>,
27    /// Default 500; max 1000.
28    pub limit: Option<i32>
29}
30
31/// struct for passing parameters to the method [`spot_get_avg_price_v3`]
32#[derive(Clone, Debug, Default)]
33pub struct SpotGetAvgPriceV3Params {
34    pub symbol: String
35}
36
37/// struct for passing parameters to the method [`spot_get_depth_v3`]
38#[derive(Clone, Debug, Default)]
39pub struct SpotGetDepthV3Params {
40    pub symbol: String,
41    /// Default 100; max 5000. <br/> If limit &gt; 5000. then the response will truncate to 5000.
42    pub limit: Option<i32>
43}
44
45/// struct for passing parameters to the method [`spot_get_historical_trades_v3`]
46#[derive(Clone, Debug, Default)]
47pub struct SpotGetHistoricalTradesV3Params {
48    pub symbol: String,
49    /// Default 500; max 1000.
50    pub limit: Option<i32>,
51    /// TradeId to fetch from. Default gets most recent trades.
52    pub from_id: Option<i64>
53}
54
55/// struct for passing parameters to the method [`spot_get_klines_v3`]
56#[derive(Clone, Debug, Default)]
57pub struct SpotGetKlinesV3Params {
58    pub symbol: String,
59    pub interval: String,
60    pub start_time: Option<i64>,
61    pub end_time: Option<i64>,
62    /// Default: 0 (UTC)
63    pub time_zone: Option<String>,
64    /// Default 500; max 1000.
65    pub limit: Option<i32>
66}
67
68/// struct for passing parameters to the method [`spot_get_ticker24hr_v3`]
69#[derive(Clone, Debug, Default)]
70pub struct SpotGetTicker24hrV3Params {
71    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, tickers for all symbols will be returned in an array. <br/><br/>          Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
72    pub symbol: Option<String>,
73    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, tickers for all symbols will be returned in an array. <br/><br/>          Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
74    pub symbols: Option<String>,
75    /// Supported values: `FULL` or `MINI`. <br/>If none provided, the default is `FULL`
76    pub r#type: Option<String>
77}
78
79/// struct for passing parameters to the method [`spot_get_ticker_book_ticker_v3`]
80#[derive(Clone, Debug, Default)]
81pub struct SpotGetTickerBookTickerV3Params {
82    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, bookTickers for all symbols will be returned in an array.          <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
83    pub symbol: Option<String>,
84    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, bookTickers for all symbols will be returned in an array.          <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
85    pub symbols: Option<String>
86}
87
88/// struct for passing parameters to the method [`spot_get_ticker_price_v3`]
89#[derive(Clone, Debug, Default)]
90pub struct SpotGetTickerPriceV3Params {
91    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, prices for all symbols will be returned in an array. <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
92    pub symbol: Option<String>,
93    /// Parameter symbol and symbols cannot be used in combination. <br/> If neither parameter is sent, prices for all symbols will be returned in an array. <br/><br/>         Examples of accepted format for the symbols parameter:          [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>          or <br/>          %5B%22BTCUSDT%22,%22BNBUSDT%22%5D
94    pub symbols: Option<String>
95}
96
97/// struct for passing parameters to the method [`spot_get_ticker_trading_day_v3`]
98#[derive(Clone, Debug, Default)]
99pub struct SpotGetTickerTradingDayV3Params {
100    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
101    pub symbol: String,
102    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
103    pub symbols: String,
104    /// Default: 0 (UTC)
105    pub time_zone: Option<String>,
106    /// Supported values: `FULL` or `MINI`. <br/>If none provided, the default is `FULL`
107    pub r#type: Option<String>
108}
109
110/// struct for passing parameters to the method [`spot_get_ticker_v3`]
111#[derive(Clone, Debug, Default)]
112pub struct SpotGetTickerV3Params {
113    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
114    pub symbol: String,
115    /// Either `symbol` or `symbols` must be provided <br/><br/> Examples of accepted format for the `symbols` parameter: <br/> [&#34;BTCUSDT&#34;,&#34;BNBUSDT&#34;] <br/>or <br/>%5B%22BTCUSDT%22,%22BNBUSDT%22%5D <br/><br/> The maximum number of `symbols` allowed in a request is 100.
116    pub symbols: String,
117    /// Defaults to `1d` if no parameter provided <br/> Supported `windowSize` values: <br/> `1m`,`2m`....`59m` for minutes <br/> `1h`, `2h`....`23h` - for hours <br/> `1d`...`7d` - for days <br/><br/> Units cannot be combined (e.g. `1d2h` is not allowed)
118    pub window_size: Option<String>,
119    /// Supported values: `FULL` or `MINI`. <br/>If none provided, the default is `FULL`
120    pub r#type: Option<String>
121}
122
123/// struct for passing parameters to the method [`spot_get_trades_v3`]
124#[derive(Clone, Debug, Default)]
125pub struct SpotGetTradesV3Params {
126    pub symbol: String,
127    /// Default 500; max 1000.
128    pub limit: Option<i32>
129}
130
131/// struct for passing parameters to the method [`spot_get_ui_klines_v3`]
132#[derive(Clone, Debug, Default)]
133pub struct SpotGetUiKlinesV3Params {
134    pub symbol: String,
135    /// See <a href=\"/docs/binance-spot-api-docs/rest-api/market-data-endpoints#kline-intervals\">`klines`</a>
136    pub interval: String,
137    pub start_time: Option<i64>,
138    pub end_time: Option<i64>,
139    /// Default: 0 (UTC)
140    pub time_zone: Option<String>,
141    /// Default 500; max 1000.
142    pub limit: Option<i32>
143}
144
145
146/// struct for typed errors of method [`spot_get_agg_trades_v3`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum SpotGetAggTradesV3Error {
150    Status4XX(models::ApiError),
151    Status5XX(models::ApiError),
152    UnknownValue(serde_json::Value),
153}
154
155/// struct for typed errors of method [`spot_get_avg_price_v3`]
156#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum SpotGetAvgPriceV3Error {
159    Status4XX(models::ApiError),
160    Status5XX(models::ApiError),
161    UnknownValue(serde_json::Value),
162}
163
164/// struct for typed errors of method [`spot_get_depth_v3`]
165#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum SpotGetDepthV3Error {
168    Status4XX(models::ApiError),
169    Status5XX(models::ApiError),
170    UnknownValue(serde_json::Value),
171}
172
173/// struct for typed errors of method [`spot_get_historical_trades_v3`]
174#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum SpotGetHistoricalTradesV3Error {
177    Status4XX(models::ApiError),
178    Status5XX(models::ApiError),
179    UnknownValue(serde_json::Value),
180}
181
182/// struct for typed errors of method [`spot_get_klines_v3`]
183#[derive(Debug, Clone, Serialize, Deserialize)]
184#[serde(untagged)]
185pub enum SpotGetKlinesV3Error {
186    Status4XX(models::ApiError),
187    Status5XX(models::ApiError),
188    UnknownValue(serde_json::Value),
189}
190
191/// struct for typed errors of method [`spot_get_ticker24hr_v3`]
192#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(untagged)]
194pub enum SpotGetTicker24hrV3Error {
195    Status4XX(models::ApiError),
196    Status5XX(models::ApiError),
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`spot_get_ticker_book_ticker_v3`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum SpotGetTickerBookTickerV3Error {
204    Status4XX(models::ApiError),
205    Status5XX(models::ApiError),
206    UnknownValue(serde_json::Value),
207}
208
209/// struct for typed errors of method [`spot_get_ticker_price_v3`]
210#[derive(Debug, Clone, Serialize, Deserialize)]
211#[serde(untagged)]
212pub enum SpotGetTickerPriceV3Error {
213    Status4XX(models::ApiError),
214    Status5XX(models::ApiError),
215    UnknownValue(serde_json::Value),
216}
217
218/// struct for typed errors of method [`spot_get_ticker_trading_day_v3`]
219#[derive(Debug, Clone, Serialize, Deserialize)]
220#[serde(untagged)]
221pub enum SpotGetTickerTradingDayV3Error {
222    Status4XX(models::ApiError),
223    Status5XX(models::ApiError),
224    UnknownValue(serde_json::Value),
225}
226
227/// struct for typed errors of method [`spot_get_ticker_v3`]
228#[derive(Debug, Clone, Serialize, Deserialize)]
229#[serde(untagged)]
230pub enum SpotGetTickerV3Error {
231    Status4XX(models::ApiError),
232    Status5XX(models::ApiError),
233    UnknownValue(serde_json::Value),
234}
235
236/// struct for typed errors of method [`spot_get_trades_v3`]
237#[derive(Debug, Clone, Serialize, Deserialize)]
238#[serde(untagged)]
239pub enum SpotGetTradesV3Error {
240    Status4XX(models::ApiError),
241    Status5XX(models::ApiError),
242    UnknownValue(serde_json::Value),
243}
244
245/// struct for typed errors of method [`spot_get_ui_klines_v3`]
246#[derive(Debug, Clone, Serialize, Deserialize)]
247#[serde(untagged)]
248pub enum SpotGetUiKlinesV3Error {
249    Status4XX(models::ApiError),
250    Status5XX(models::ApiError),
251    UnknownValue(serde_json::Value),
252}
253
254
255/// Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.
256pub async fn spot_get_agg_trades_v3(configuration: &configuration::Configuration, params: SpotGetAggTradesV3Params) -> Result<Vec<models::SpotGetAggTradesV3RespItem>, Error<SpotGetAggTradesV3Error>> {
257
258    let uri_str = format!("{}/api/v3/aggTrades", configuration.base_path);
259    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
260
261    // Create a mutable vector for query parameters
262    let mut query_params: Vec<(String, String)> = Vec::new();
263
264    query_params.push(("symbol".to_string(), params.symbol.to_string()));
265    if let Some(ref param_value) = params.from_id {
266        query_params.push(("fromId".to_string(), param_value.to_string()));
267    }
268    if let Some(ref param_value) = params.start_time {
269        query_params.push(("startTime".to_string(), param_value.to_string()));
270    }
271    if let Some(ref param_value) = params.end_time {
272        query_params.push(("endTime".to_string(), param_value.to_string()));
273    }
274    if let Some(ref param_value) = params.limit {
275        query_params.push(("limit".to_string(), param_value.to_string()));
276    }
277
278    // Create header parameters collection
279    let mut header_params = std::collections::HashMap::new();
280
281    // Handle Binance Auth first if configured
282    if let Some(ref binance_auth) = configuration.binance_auth {
283        // Add API key to headers
284        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
285        
286        // Generate request body for signing (if any)
287        let body_string: Option<Vec<u8>> = None;
288        
289        // Sign the request
290        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
291            Ok(sig) => sig,
292            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
293        };
294        
295        // Add signature to query params
296        query_params.push(("signature".to_string(), signature));
297    }
298
299    // Apply all query parameters
300    if !query_params.is_empty() {
301        req_builder = req_builder.query(&query_params);
302    }
303
304
305    // Add user agent if configured
306    if let Some(ref user_agent) = configuration.user_agent {
307        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308    }
309
310    // Apply all header parameters
311    for (header_name, header_value) in header_params {
312        req_builder = req_builder.header(&header_name, &header_value);
313    }
314
315
316    let req = req_builder.build()?;
317    let resp = configuration.client.execute(req).await?;
318
319    let status = resp.status();
320    let content_type = resp
321        .headers()
322        .get("content-type")
323        .and_then(|v| v.to_str().ok())
324        .unwrap_or("application/octet-stream");
325    let content_type = super::ContentType::from(content_type);
326
327    if !status.is_client_error() && !status.is_server_error() {
328        let content = resp.text().await?;
329        match content_type {
330            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
331            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetAggTradesV3RespItem&gt;`"))),
332            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::SpotGetAggTradesV3RespItem&gt;`")))),
333        }
334    } else {
335        let content = resp.text().await?;
336        let entity: Option<SpotGetAggTradesV3Error> = serde_json::from_str(&content).ok();
337        Err(Error::ResponseError(ResponseContent { status, content, entity }))
338    }
339}
340
341/// Current average price for a symbol.
342pub async fn spot_get_avg_price_v3(configuration: &configuration::Configuration, params: SpotGetAvgPriceV3Params) -> Result<models::SpotGetAvgPriceV3Resp, Error<SpotGetAvgPriceV3Error>> {
343
344    let uri_str = format!("{}/api/v3/avgPrice", configuration.base_path);
345    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
346
347    // Create a mutable vector for query parameters
348    let mut query_params: Vec<(String, String)> = Vec::new();
349
350    query_params.push(("symbol".to_string(), params.symbol.to_string()));
351
352    // Create header parameters collection
353    let mut header_params = std::collections::HashMap::new();
354
355    // Handle Binance Auth first if configured
356    if let Some(ref binance_auth) = configuration.binance_auth {
357        // Add API key to headers
358        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
359        
360        // Generate request body for signing (if any)
361        let body_string: Option<Vec<u8>> = None;
362        
363        // Sign the request
364        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
365            Ok(sig) => sig,
366            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
367        };
368        
369        // Add signature to query params
370        query_params.push(("signature".to_string(), signature));
371    }
372
373    // Apply all query parameters
374    if !query_params.is_empty() {
375        req_builder = req_builder.query(&query_params);
376    }
377
378
379    // Add user agent if configured
380    if let Some(ref user_agent) = configuration.user_agent {
381        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
382    }
383
384    // Apply all header parameters
385    for (header_name, header_value) in header_params {
386        req_builder = req_builder.header(&header_name, &header_value);
387    }
388
389
390    let req = req_builder.build()?;
391    let resp = configuration.client.execute(req).await?;
392
393    let status = resp.status();
394    let content_type = resp
395        .headers()
396        .get("content-type")
397        .and_then(|v| v.to_str().ok())
398        .unwrap_or("application/octet-stream");
399    let content_type = super::ContentType::from(content_type);
400
401    if !status.is_client_error() && !status.is_server_error() {
402        let content = resp.text().await?;
403        match content_type {
404            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
405            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetAvgPriceV3Resp`"))),
406            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetAvgPriceV3Resp`")))),
407        }
408    } else {
409        let content = resp.text().await?;
410        let entity: Option<SpotGetAvgPriceV3Error> = serde_json::from_str(&content).ok();
411        Err(Error::ResponseError(ResponseContent { status, content, entity }))
412    }
413}
414
415pub async fn spot_get_depth_v3(configuration: &configuration::Configuration, params: SpotGetDepthV3Params) -> Result<models::SpotGetDepthV3Resp, Error<SpotGetDepthV3Error>> {
416
417    let uri_str = format!("{}/api/v3/depth", configuration.base_path);
418    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
419
420    // Create a mutable vector for query parameters
421    let mut query_params: Vec<(String, String)> = Vec::new();
422
423    query_params.push(("symbol".to_string(), params.symbol.to_string()));
424    if let Some(ref param_value) = params.limit {
425        query_params.push(("limit".to_string(), param_value.to_string()));
426    }
427
428    // Create header parameters collection
429    let mut header_params = std::collections::HashMap::new();
430
431    // Handle Binance Auth first if configured
432    if let Some(ref binance_auth) = configuration.binance_auth {
433        // Add API key to headers
434        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
435        
436        // Generate request body for signing (if any)
437        let body_string: Option<Vec<u8>> = None;
438        
439        // Sign the request
440        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
441            Ok(sig) => sig,
442            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
443        };
444        
445        // Add signature to query params
446        query_params.push(("signature".to_string(), signature));
447    }
448
449    // Apply all query parameters
450    if !query_params.is_empty() {
451        req_builder = req_builder.query(&query_params);
452    }
453
454
455    // Add user agent if configured
456    if let Some(ref user_agent) = configuration.user_agent {
457        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
458    }
459
460    // Apply all header parameters
461    for (header_name, header_value) in header_params {
462        req_builder = req_builder.header(&header_name, &header_value);
463    }
464
465
466    let req = req_builder.build()?;
467    let resp = configuration.client.execute(req).await?;
468
469    let status = resp.status();
470    let content_type = resp
471        .headers()
472        .get("content-type")
473        .and_then(|v| v.to_str().ok())
474        .unwrap_or("application/octet-stream");
475    let content_type = super::ContentType::from(content_type);
476
477    if !status.is_client_error() && !status.is_server_error() {
478        let content = resp.text().await?;
479        match content_type {
480            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
481            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetDepthV3Resp`"))),
482            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetDepthV3Resp`")))),
483        }
484    } else {
485        let content = resp.text().await?;
486        let entity: Option<SpotGetDepthV3Error> = serde_json::from_str(&content).ok();
487        Err(Error::ResponseError(ResponseContent { status, content, entity }))
488    }
489}
490
491/// Get older trades.
492pub async fn spot_get_historical_trades_v3(configuration: &configuration::Configuration, params: SpotGetHistoricalTradesV3Params) -> Result<Vec<models::SpotGetHistoricalTradesV3RespItem>, Error<SpotGetHistoricalTradesV3Error>> {
493
494    let uri_str = format!("{}/api/v3/historicalTrades", configuration.base_path);
495    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
496
497    // Create a mutable vector for query parameters
498    let mut query_params: Vec<(String, String)> = Vec::new();
499
500    query_params.push(("symbol".to_string(), params.symbol.to_string()));
501    if let Some(ref param_value) = params.limit {
502        query_params.push(("limit".to_string(), param_value.to_string()));
503    }
504    if let Some(ref param_value) = params.from_id {
505        query_params.push(("fromId".to_string(), param_value.to_string()));
506    }
507
508    // Create header parameters collection
509    let mut header_params = std::collections::HashMap::new();
510
511    // Handle Binance Auth first if configured
512    if let Some(ref binance_auth) = configuration.binance_auth {
513        // Add API key to headers
514        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
515        
516        // Generate request body for signing (if any)
517        let body_string: Option<Vec<u8>> = None;
518        
519        // Sign the request
520        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
521            Ok(sig) => sig,
522            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
523        };
524        
525        // Add signature to query params
526        query_params.push(("signature".to_string(), signature));
527    }
528
529    // Apply all query parameters
530    if !query_params.is_empty() {
531        req_builder = req_builder.query(&query_params);
532    }
533
534
535    // Add user agent if configured
536    if let Some(ref user_agent) = configuration.user_agent {
537        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
538    }
539
540    // Apply all header parameters
541    for (header_name, header_value) in header_params {
542        req_builder = req_builder.header(&header_name, &header_value);
543    }
544
545
546    let req = req_builder.build()?;
547    let resp = configuration.client.execute(req).await?;
548
549    let status = resp.status();
550    let content_type = resp
551        .headers()
552        .get("content-type")
553        .and_then(|v| v.to_str().ok())
554        .unwrap_or("application/octet-stream");
555    let content_type = super::ContentType::from(content_type);
556
557    if !status.is_client_error() && !status.is_server_error() {
558        let content = resp.text().await?;
559        match content_type {
560            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
561            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetHistoricalTradesV3RespItem&gt;`"))),
562            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::SpotGetHistoricalTradesV3RespItem&gt;`")))),
563        }
564    } else {
565        let content = resp.text().await?;
566        let entity: Option<SpotGetHistoricalTradesV3Error> = serde_json::from_str(&content).ok();
567        Err(Error::ResponseError(ResponseContent { status, content, entity }))
568    }
569}
570
571/// Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
572pub async fn spot_get_klines_v3(configuration: &configuration::Configuration, params: SpotGetKlinesV3Params) -> Result<Vec<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>, Error<SpotGetKlinesV3Error>> {
573
574    let uri_str = format!("{}/api/v3/klines", configuration.base_path);
575    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
576
577    // Create a mutable vector for query parameters
578    let mut query_params: Vec<(String, String)> = Vec::new();
579
580    query_params.push(("symbol".to_string(), params.symbol.to_string()));
581    query_params.push(("interval".to_string(), params.interval.to_string()));
582    if let Some(ref param_value) = params.start_time {
583        query_params.push(("startTime".to_string(), param_value.to_string()));
584    }
585    if let Some(ref param_value) = params.end_time {
586        query_params.push(("endTime".to_string(), param_value.to_string()));
587    }
588    if let Some(ref param_value) = params.time_zone {
589        query_params.push(("timeZone".to_string(), param_value.to_string()));
590    }
591    if let Some(ref param_value) = params.limit {
592        query_params.push(("limit".to_string(), param_value.to_string()));
593    }
594
595    // Create header parameters collection
596    let mut header_params = std::collections::HashMap::new();
597
598    // Handle Binance Auth first if configured
599    if let Some(ref binance_auth) = configuration.binance_auth {
600        // Add API key to headers
601        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
602        
603        // Generate request body for signing (if any)
604        let body_string: Option<Vec<u8>> = None;
605        
606        // Sign the request
607        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
608            Ok(sig) => sig,
609            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
610        };
611        
612        // Add signature to query params
613        query_params.push(("signature".to_string(), signature));
614    }
615
616    // Apply all query parameters
617    if !query_params.is_empty() {
618        req_builder = req_builder.query(&query_params);
619    }
620
621
622    // Add user agent if configured
623    if let Some(ref user_agent) = configuration.user_agent {
624        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
625    }
626
627    // Apply all header parameters
628    for (header_name, header_value) in header_params {
629        req_builder = req_builder.header(&header_name, &header_value);
630    }
631
632
633    let req = req_builder.build()?;
634    let resp = configuration.client.execute(req).await?;
635
636    let status = resp.status();
637    let content_type = resp
638        .headers()
639        .get("content-type")
640        .and_then(|v| v.to_str().ok())
641        .unwrap_or("application/octet-stream");
642    let content_type = super::ContentType::from(content_type);
643
644    if !status.is_client_error() && !status.is_server_error() {
645        let content = resp.text().await?;
646        match content_type {
647            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
648            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotGetKlinesV3200ResponseInnerInner&gt;&gt;`"))),
649            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotGetKlinesV3200ResponseInnerInner&gt;&gt;`")))),
650        }
651    } else {
652        let content = resp.text().await?;
653        let entity: Option<SpotGetKlinesV3Error> = serde_json::from_str(&content).ok();
654        Err(Error::ResponseError(ResponseContent { status, content, entity }))
655    }
656}
657
658/// 24 hour rolling window price change statistics. Careful when accessing this with no symbol.
659pub async fn spot_get_ticker24hr_v3(configuration: &configuration::Configuration, params: SpotGetTicker24hrV3Params) -> Result<models::SpotGetTicker24hrV3Resp, Error<SpotGetTicker24hrV3Error>> {
660
661    let uri_str = format!("{}/api/v3/ticker/24hr", configuration.base_path);
662    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
663
664    // Create a mutable vector for query parameters
665    let mut query_params: Vec<(String, String)> = Vec::new();
666
667    if let Some(ref param_value) = params.symbol {
668        query_params.push(("symbol".to_string(), param_value.to_string()));
669    }
670    if let Some(ref param_value) = params.symbols {
671        query_params.push(("symbols".to_string(), param_value.to_string()));
672    }
673    if let Some(ref param_value) = params.r#type {
674        query_params.push(("type".to_string(), param_value.to_string()));
675    }
676
677    // Create header parameters collection
678    let mut header_params = std::collections::HashMap::new();
679
680    // Handle Binance Auth first if configured
681    if let Some(ref binance_auth) = configuration.binance_auth {
682        // Add API key to headers
683        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
684        
685        // Generate request body for signing (if any)
686        let body_string: Option<Vec<u8>> = None;
687        
688        // Sign the request
689        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
690            Ok(sig) => sig,
691            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
692        };
693        
694        // Add signature to query params
695        query_params.push(("signature".to_string(), signature));
696    }
697
698    // Apply all query parameters
699    if !query_params.is_empty() {
700        req_builder = req_builder.query(&query_params);
701    }
702
703
704    // Add user agent if configured
705    if let Some(ref user_agent) = configuration.user_agent {
706        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
707    }
708
709    // Apply all header parameters
710    for (header_name, header_value) in header_params {
711        req_builder = req_builder.header(&header_name, &header_value);
712    }
713
714
715    let req = req_builder.build()?;
716    let resp = configuration.client.execute(req).await?;
717
718    let status = resp.status();
719    let content_type = resp
720        .headers()
721        .get("content-type")
722        .and_then(|v| v.to_str().ok())
723        .unwrap_or("application/octet-stream");
724    let content_type = super::ContentType::from(content_type);
725
726    if !status.is_client_error() && !status.is_server_error() {
727        let content = resp.text().await?;
728        match content_type {
729            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
730            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTicker24hrV3Resp`"))),
731            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetTicker24hrV3Resp`")))),
732        }
733    } else {
734        let content = resp.text().await?;
735        let entity: Option<SpotGetTicker24hrV3Error> = serde_json::from_str(&content).ok();
736        Err(Error::ResponseError(ResponseContent { status, content, entity }))
737    }
738}
739
740/// Best price/qty on the order book for a symbol or symbols.
741pub async fn spot_get_ticker_book_ticker_v3(configuration: &configuration::Configuration, params: SpotGetTickerBookTickerV3Params) -> Result<models::SpotGetTickerBookTickerV3Resp, Error<SpotGetTickerBookTickerV3Error>> {
742
743    let uri_str = format!("{}/api/v3/ticker/bookTicker", configuration.base_path);
744    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
745
746    // Create a mutable vector for query parameters
747    let mut query_params: Vec<(String, String)> = Vec::new();
748
749    if let Some(ref param_value) = params.symbol {
750        query_params.push(("symbol".to_string(), param_value.to_string()));
751    }
752    if let Some(ref param_value) = params.symbols {
753        query_params.push(("symbols".to_string(), param_value.to_string()));
754    }
755
756    // Create header parameters collection
757    let mut header_params = std::collections::HashMap::new();
758
759    // Handle Binance Auth first if configured
760    if let Some(ref binance_auth) = configuration.binance_auth {
761        // Add API key to headers
762        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
763        
764        // Generate request body for signing (if any)
765        let body_string: Option<Vec<u8>> = None;
766        
767        // Sign the request
768        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
769            Ok(sig) => sig,
770            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
771        };
772        
773        // Add signature to query params
774        query_params.push(("signature".to_string(), signature));
775    }
776
777    // Apply all query parameters
778    if !query_params.is_empty() {
779        req_builder = req_builder.query(&query_params);
780    }
781
782
783    // Add user agent if configured
784    if let Some(ref user_agent) = configuration.user_agent {
785        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
786    }
787
788    // Apply all header parameters
789    for (header_name, header_value) in header_params {
790        req_builder = req_builder.header(&header_name, &header_value);
791    }
792
793
794    let req = req_builder.build()?;
795    let resp = configuration.client.execute(req).await?;
796
797    let status = resp.status();
798    let content_type = resp
799        .headers()
800        .get("content-type")
801        .and_then(|v| v.to_str().ok())
802        .unwrap_or("application/octet-stream");
803    let content_type = super::ContentType::from(content_type);
804
805    if !status.is_client_error() && !status.is_server_error() {
806        let content = resp.text().await?;
807        match content_type {
808            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
809            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerBookTickerV3Resp`"))),
810            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetTickerBookTickerV3Resp`")))),
811        }
812    } else {
813        let content = resp.text().await?;
814        let entity: Option<SpotGetTickerBookTickerV3Error> = serde_json::from_str(&content).ok();
815        Err(Error::ResponseError(ResponseContent { status, content, entity }))
816    }
817}
818
819/// Latest price for a symbol or symbols.
820pub async fn spot_get_ticker_price_v3(configuration: &configuration::Configuration, params: SpotGetTickerPriceV3Params) -> Result<models::SpotGetTickerPriceV3Resp, Error<SpotGetTickerPriceV3Error>> {
821
822    let uri_str = format!("{}/api/v3/ticker/price", configuration.base_path);
823    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
824
825    // Create a mutable vector for query parameters
826    let mut query_params: Vec<(String, String)> = Vec::new();
827
828    if let Some(ref param_value) = params.symbol {
829        query_params.push(("symbol".to_string(), param_value.to_string()));
830    }
831    if let Some(ref param_value) = params.symbols {
832        query_params.push(("symbols".to_string(), param_value.to_string()));
833    }
834
835    // Create header parameters collection
836    let mut header_params = std::collections::HashMap::new();
837
838    // Handle Binance Auth first if configured
839    if let Some(ref binance_auth) = configuration.binance_auth {
840        // Add API key to headers
841        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
842        
843        // Generate request body for signing (if any)
844        let body_string: Option<Vec<u8>> = None;
845        
846        // Sign the request
847        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
848            Ok(sig) => sig,
849            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
850        };
851        
852        // Add signature to query params
853        query_params.push(("signature".to_string(), signature));
854    }
855
856    // Apply all query parameters
857    if !query_params.is_empty() {
858        req_builder = req_builder.query(&query_params);
859    }
860
861
862    // Add user agent if configured
863    if let Some(ref user_agent) = configuration.user_agent {
864        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
865    }
866
867    // Apply all header parameters
868    for (header_name, header_value) in header_params {
869        req_builder = req_builder.header(&header_name, &header_value);
870    }
871
872
873    let req = req_builder.build()?;
874    let resp = configuration.client.execute(req).await?;
875
876    let status = resp.status();
877    let content_type = resp
878        .headers()
879        .get("content-type")
880        .and_then(|v| v.to_str().ok())
881        .unwrap_or("application/octet-stream");
882    let content_type = super::ContentType::from(content_type);
883
884    if !status.is_client_error() && !status.is_server_error() {
885        let content = resp.text().await?;
886        match content_type {
887            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
888            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerPriceV3Resp`"))),
889            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetTickerPriceV3Resp`")))),
890        }
891    } else {
892        let content = resp.text().await?;
893        let entity: Option<SpotGetTickerPriceV3Error> = serde_json::from_str(&content).ok();
894        Err(Error::ResponseError(ResponseContent { status, content, entity }))
895    }
896}
897
898/// Price change statistics for a trading day. 4 for each requested symbol.  The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
899pub async fn spot_get_ticker_trading_day_v3(configuration: &configuration::Configuration, params: SpotGetTickerTradingDayV3Params) -> Result<models::SpotGetTickerTradingDayV3Resp, Error<SpotGetTickerTradingDayV3Error>> {
900
901    let uri_str = format!("{}/api/v3/ticker/tradingDay", configuration.base_path);
902    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
903
904    // Create a mutable vector for query parameters
905    let mut query_params: Vec<(String, String)> = Vec::new();
906
907    query_params.push(("symbol".to_string(), params.symbol.to_string()));
908    query_params.push(("symbols".to_string(), params.symbols.to_string()));
909    if let Some(ref param_value) = params.time_zone {
910        query_params.push(("timeZone".to_string(), param_value.to_string()));
911    }
912    if let Some(ref param_value) = params.r#type {
913        query_params.push(("type".to_string(), param_value.to_string()));
914    }
915
916    // Create header parameters collection
917    let mut header_params = std::collections::HashMap::new();
918
919    // Handle Binance Auth first if configured
920    if let Some(ref binance_auth) = configuration.binance_auth {
921        // Add API key to headers
922        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
923        
924        // Generate request body for signing (if any)
925        let body_string: Option<Vec<u8>> = None;
926        
927        // Sign the request
928        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
929            Ok(sig) => sig,
930            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
931        };
932        
933        // Add signature to query params
934        query_params.push(("signature".to_string(), signature));
935    }
936
937    // Apply all query parameters
938    if !query_params.is_empty() {
939        req_builder = req_builder.query(&query_params);
940    }
941
942
943    // Add user agent if configured
944    if let Some(ref user_agent) = configuration.user_agent {
945        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
946    }
947
948    // Apply all header parameters
949    for (header_name, header_value) in header_params {
950        req_builder = req_builder.header(&header_name, &header_value);
951    }
952
953
954    let req = req_builder.build()?;
955    let resp = configuration.client.execute(req).await?;
956
957    let status = resp.status();
958    let content_type = resp
959        .headers()
960        .get("content-type")
961        .and_then(|v| v.to_str().ok())
962        .unwrap_or("application/octet-stream");
963    let content_type = super::ContentType::from(content_type);
964
965    if !status.is_client_error() && !status.is_server_error() {
966        let content = resp.text().await?;
967        match content_type {
968            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
969            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerTradingDayV3Resp`"))),
970            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetTickerTradingDayV3Resp`")))),
971        }
972    } else {
973        let content = resp.text().await?;
974        let entity: Option<SpotGetTickerTradingDayV3Error> = serde_json::from_str(&content).ok();
975        Err(Error::ResponseError(ResponseContent { status, content, entity }))
976    }
977}
978
979/// Note: This endpoint is different from the GET /api/v3/ticker/24hr endpoint. The window used to compute statistics will be no more than 59999ms from the requested windowSize. openTime for /api/v3/ticker always starts on a minute, while the closeTime is the current time of the request. As such, the effective window will be up to 59999ms wider than windowSize. E.g. If the closeTime is 1641287867099 (January 04, 2022 09:17:47:099 UTC) , and the windowSize is 1d. the openTime will be: 1641201420000 (January 3, 2022, 09:17:00) 4 for each requested symbol regardless of windowSize.  The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
980pub async fn spot_get_ticker_v3(configuration: &configuration::Configuration, params: SpotGetTickerV3Params) -> Result<models::SpotGetTickerV3Resp, Error<SpotGetTickerV3Error>> {
981
982    let uri_str = format!("{}/api/v3/ticker", configuration.base_path);
983    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
984
985    // Create a mutable vector for query parameters
986    let mut query_params: Vec<(String, String)> = Vec::new();
987
988    query_params.push(("symbol".to_string(), params.symbol.to_string()));
989    query_params.push(("symbols".to_string(), params.symbols.to_string()));
990    if let Some(ref param_value) = params.window_size {
991        query_params.push(("windowSize".to_string(), param_value.to_string()));
992    }
993    if let Some(ref param_value) = params.r#type {
994        query_params.push(("type".to_string(), param_value.to_string()));
995    }
996
997    // Create header parameters collection
998    let mut header_params = std::collections::HashMap::new();
999
1000    // Handle Binance Auth first if configured
1001    if let Some(ref binance_auth) = configuration.binance_auth {
1002        // Add API key to headers
1003        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1004        
1005        // Generate request body for signing (if any)
1006        let body_string: Option<Vec<u8>> = None;
1007        
1008        // Sign the request
1009        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1010            Ok(sig) => sig,
1011            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1012        };
1013        
1014        // Add signature to query params
1015        query_params.push(("signature".to_string(), signature));
1016    }
1017
1018    // Apply all query parameters
1019    if !query_params.is_empty() {
1020        req_builder = req_builder.query(&query_params);
1021    }
1022
1023
1024    // Add user agent if configured
1025    if let Some(ref user_agent) = configuration.user_agent {
1026        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1027    }
1028
1029    // Apply all header parameters
1030    for (header_name, header_value) in header_params {
1031        req_builder = req_builder.header(&header_name, &header_value);
1032    }
1033
1034
1035    let req = req_builder.build()?;
1036    let resp = configuration.client.execute(req).await?;
1037
1038    let status = resp.status();
1039    let content_type = resp
1040        .headers()
1041        .get("content-type")
1042        .and_then(|v| v.to_str().ok())
1043        .unwrap_or("application/octet-stream");
1044    let content_type = super::ContentType::from(content_type);
1045
1046    if !status.is_client_error() && !status.is_server_error() {
1047        let content = resp.text().await?;
1048        match content_type {
1049            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1050            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetTickerV3Resp`"))),
1051            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetTickerV3Resp`")))),
1052        }
1053    } else {
1054        let content = resp.text().await?;
1055        let entity: Option<SpotGetTickerV3Error> = serde_json::from_str(&content).ok();
1056        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1057    }
1058}
1059
1060/// Get recent trades.
1061pub async fn spot_get_trades_v3(configuration: &configuration::Configuration, params: SpotGetTradesV3Params) -> Result<Vec<models::SpotGetTradesV3RespItem>, Error<SpotGetTradesV3Error>> {
1062
1063    let uri_str = format!("{}/api/v3/trades", configuration.base_path);
1064    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1065
1066    // Create a mutable vector for query parameters
1067    let mut query_params: Vec<(String, String)> = Vec::new();
1068
1069    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1070    if let Some(ref param_value) = params.limit {
1071        query_params.push(("limit".to_string(), param_value.to_string()));
1072    }
1073
1074    // Create header parameters collection
1075    let mut header_params = std::collections::HashMap::new();
1076
1077    // Handle Binance Auth first if configured
1078    if let Some(ref binance_auth) = configuration.binance_auth {
1079        // Add API key to headers
1080        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1081        
1082        // Generate request body for signing (if any)
1083        let body_string: Option<Vec<u8>> = None;
1084        
1085        // Sign the request
1086        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1087            Ok(sig) => sig,
1088            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1089        };
1090        
1091        // Add signature to query params
1092        query_params.push(("signature".to_string(), signature));
1093    }
1094
1095    // Apply all query parameters
1096    if !query_params.is_empty() {
1097        req_builder = req_builder.query(&query_params);
1098    }
1099
1100
1101    // Add user agent if configured
1102    if let Some(ref user_agent) = configuration.user_agent {
1103        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1104    }
1105
1106    // Apply all header parameters
1107    for (header_name, header_value) in header_params {
1108        req_builder = req_builder.header(&header_name, &header_value);
1109    }
1110
1111
1112    let req = req_builder.build()?;
1113    let resp = configuration.client.execute(req).await?;
1114
1115    let status = resp.status();
1116    let content_type = resp
1117        .headers()
1118        .get("content-type")
1119        .and_then(|v| v.to_str().ok())
1120        .unwrap_or("application/octet-stream");
1121    let content_type = super::ContentType::from(content_type);
1122
1123    if !status.is_client_error() && !status.is_server_error() {
1124        let content = resp.text().await?;
1125        match content_type {
1126            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1127            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetTradesV3RespItem&gt;`"))),
1128            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::SpotGetTradesV3RespItem&gt;`")))),
1129        }
1130    } else {
1131        let content = resp.text().await?;
1132        let entity: Option<SpotGetTradesV3Error> = serde_json::from_str(&content).ok();
1133        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1134    }
1135}
1136
1137/// The request is similar to klines having the same parameters and response. uiKlines return modified kline data, optimized for presentation of candlestick charts.
1138pub async fn spot_get_ui_klines_v3(configuration: &configuration::Configuration, params: SpotGetUiKlinesV3Params) -> Result<Vec<Vec<models::SpotGetKlinesV3200ResponseInnerInner>>, Error<SpotGetUiKlinesV3Error>> {
1139
1140    let uri_str = format!("{}/api/v3/uiKlines", configuration.base_path);
1141    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1142
1143    // Create a mutable vector for query parameters
1144    let mut query_params: Vec<(String, String)> = Vec::new();
1145
1146    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1147    query_params.push(("interval".to_string(), params.interval.to_string()));
1148    if let Some(ref param_value) = params.start_time {
1149        query_params.push(("startTime".to_string(), param_value.to_string()));
1150    }
1151    if let Some(ref param_value) = params.end_time {
1152        query_params.push(("endTime".to_string(), param_value.to_string()));
1153    }
1154    if let Some(ref param_value) = params.time_zone {
1155        query_params.push(("timeZone".to_string(), param_value.to_string()));
1156    }
1157    if let Some(ref param_value) = params.limit {
1158        query_params.push(("limit".to_string(), param_value.to_string()));
1159    }
1160
1161    // Create header parameters collection
1162    let mut header_params = std::collections::HashMap::new();
1163
1164    // Handle Binance Auth first if configured
1165    if let Some(ref binance_auth) = configuration.binance_auth {
1166        // Add API key to headers
1167        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1168        
1169        // Generate request body for signing (if any)
1170        let body_string: Option<Vec<u8>> = None;
1171        
1172        // Sign the request
1173        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1174            Ok(sig) => sig,
1175            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1176        };
1177        
1178        // Add signature to query params
1179        query_params.push(("signature".to_string(), signature));
1180    }
1181
1182    // Apply all query parameters
1183    if !query_params.is_empty() {
1184        req_builder = req_builder.query(&query_params);
1185    }
1186
1187
1188    // Add user agent if configured
1189    if let Some(ref user_agent) = configuration.user_agent {
1190        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1191    }
1192
1193    // Apply all header parameters
1194    for (header_name, header_value) in header_params {
1195        req_builder = req_builder.header(&header_name, &header_value);
1196    }
1197
1198
1199    let req = req_builder.build()?;
1200    let resp = configuration.client.execute(req).await?;
1201
1202    let status = resp.status();
1203    let content_type = resp
1204        .headers()
1205        .get("content-type")
1206        .and_then(|v| v.to_str().ok())
1207        .unwrap_or("application/octet-stream");
1208    let content_type = super::ContentType::from(content_type);
1209
1210    if !status.is_client_error() && !status.is_server_error() {
1211        let content = resp.text().await?;
1212        match content_type {
1213            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1214            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotGetKlinesV3200ResponseInnerInner&gt;&gt;`"))),
1215            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotGetKlinesV3200ResponseInnerInner&gt;&gt;`")))),
1216        }
1217    } else {
1218        let content = resp.text().await?;
1219        let entity: Option<SpotGetUiKlinesV3Error> = serde_json::from_str(&content).ok();
1220        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1221    }
1222}
1223