bpx_api_client/routes/
history.rs

1use bpx_api_types::fill::{Fill, FillsHistoryParams};
2
3use crate::BpxClient;
4use crate::error::{Error, Result};
5
6#[doc(hidden)]
7pub const API_FILLS_HISTORY: &str = "/wapi/v1/history/fills";
8
9impl BpxClient {
10    /// Fetches historical fills with optional filtering and pagination parameters.
11    pub async fn get_historical_fills(&self, params: FillsHistoryParams) -> Result<Vec<Fill>> {
12        let query_string = serde_qs::to_string(&params)
13            .map_err(|e| Error::UrlParseError(e.to_string().into_boxed_str()))?;
14        let mut url = self.base_url.join(API_FILLS_HISTORY)?;
15        url.set_query(Some(&query_string));
16        let res = self.get(url).await?;
17        res.json().await.map_err(Into::into)
18    }
19}