pub struct WithdrawalClient { /* private fields */ }Expand description
Client for dealing with withdrawals and sub accounts.
Implementations§
Source§impl WithdrawalClient
impl WithdrawalClient
Sourcepub fn connect<A, S, U>(api_key: A, secret_key: S, url: U) -> Result<Self>
pub fn connect<A, S, U>(api_key: A, secret_key: S, url: U) -> Result<Self>
Creates new client instance.
§Example
use tokio_binance::{WithdrawalClient, BINANCE_US_URL};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WithdrawalClient::connect("<api-key>", "<secret-key>", BINANCE_US_URL)?;
Ok(())
}Sourcepub fn withdraw<'a>(
&self,
asset: &'a str,
address: &'a str,
amount: f64,
) -> ParamBuilder<'a, '_, WithdrawParams>
pub fn withdraw<'a>( &self, asset: &'a str, address: &'a str, amount: f64, ) -> ParamBuilder<'a, '_, WithdrawParams>
Submit a withdraw request.
§Example
use serde_json::Value;
let response = client
.withdraw("BNB", "<public-address>", 5.00)
//optional: Secondary address identifier for coins like XRP,XMR etc.
.with_address_tag("<tag>")
// optional: Description of the address.
.with_name("<description>")
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_deposit_history(&self) -> ParamBuilder<'_, '_, DepositHistoryParams>
pub fn get_deposit_history(&self) -> ParamBuilder<'_, '_, DepositHistoryParams>
Fetch deposit history.
§Example
use chrono::{Utc, Duration};
use serde_json::Value;
let end = Utc::now();
let start = end - Duration::hours(23);
let response = client
.get_deposit_history()
// optional: filter by asset; gets all assets by default.
.with_asset("BNB")
// optional: 0(0:pending,6: credited but cannot withdraw, 1:success)
.with_status(1)
// optional: get deposits from; gets the most recent deposits by default.
.with_start_time(start)
// optional: get deposits until; default is now.
.with_end_time(end)
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_withdraw_history(
&self,
) -> ParamBuilder<'_, '_, WithdrawHistoryParams>
pub fn get_withdraw_history( &self, ) -> ParamBuilder<'_, '_, WithdrawHistoryParams>
Fetch withdraw history.
§Example
use chrono::{Utc, Duration};
use serde_json::Value;
let end = Utc::now();
let start = end - Duration::hours(23);
let response = client
.get_withdraw_history()
// optional: filter by asset; gets all assets by default.
.with_asset("BNB")
// optional: 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6Completed)
.with_status(6)
// optional: get deposits from; gets the most recent deposits by default.
.with_start_time(start)
// optional: get deposits until; default is now.
.with_end_time(end)
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_deposit_address<'a>(
&self,
asset: &'a str,
) -> ParamBuilder<'a, '_, DepositAddressParams>
pub fn get_deposit_address<'a>( &self, asset: &'a str, ) -> ParamBuilder<'a, '_, DepositAddressParams>
Fetch deposit address.
§Example
use serde_json::Value;
let response = client
.get_deposit_address("BNB")
// optional: Boolean.
.with_status(true)
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_account_status(&self) -> ParamBuilder<'_, '_, AccountStatusParams>
pub fn get_account_status(&self) -> ParamBuilder<'_, '_, AccountStatusParams>
Fetch account status detail.
§Example
use serde_json::Value;
let response = client
.get_account_status()
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_system_status(&self) -> ParamBuilder<'_, '_, SystemStatusParams>
pub fn get_system_status(&self) -> ParamBuilder<'_, '_, SystemStatusParams>
Fetch system status.
§Example
use serde_json::Value;
let response = client
.get_system_status()
.json::<Value>()
.await?;Sourcepub fn get_api_status(&self) -> ParamBuilder<'_, '_, ApiStatusParams>
pub fn get_api_status(&self) -> ParamBuilder<'_, '_, ApiStatusParams>
Fetch account api trading status detail.
§Example
use serde_json::Value;
let response = client
.get_api_status()
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_dustlog(&self) -> ParamBuilder<'_, '_, DustlogParams>
pub fn get_dustlog(&self) -> ParamBuilder<'_, '_, DustlogParams>
Fetch small amounts of assets exchanged BNB records.
§Example
use serde_json::Value;
let response = client
.get_dustlog()
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_trade_fee(&self) -> ParamBuilder<'_, '_, TradeFeeParams>
pub fn get_trade_fee(&self) -> ParamBuilder<'_, '_, TradeFeeParams>
Fetch trade fee.
§Example
use serde_json::Value;
let response = client
.get_trade_fee()
// optional: filter by symbol; gets all symbols by default.
.with_symbol("BNBUSDT")
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_asset_detail(&self) -> ParamBuilder<'_, '_, AssetDetailParams>
pub fn get_asset_detail(&self) -> ParamBuilder<'_, '_, AssetDetailParams>
Fetch asset detail.
§Example
use serde_json::Value;
let response = client
.get_asset_detail()
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_sub_accounts(&self) -> ParamBuilder<'_, '_, SubAccountParams>
pub fn get_sub_accounts(&self) -> ParamBuilder<'_, '_, SubAccountParams>
Fetch sub account list.
§Example
use serde_json::Value;
let response = client
.get_sub_accounts()
// optional: Sub-account email.
.with_email("<email>")
// optional: Sub-account status: enabled or disabled.
.with_status("enabled")
// optional: default value: 1.
.with_page(2)
// optional: limit the amount of sub accounts; default 500.
.with_limit(100)
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_transfer_history<'a>(
&self,
email: &'a str,
) -> ParamBuilder<'a, '_, SubAccountTranferParams>
pub fn get_transfer_history<'a>( &self, email: &'a str, ) -> ParamBuilder<'a, '_, SubAccountTranferParams>
Fetch transfer history list
§Example
use chrono::{Utc, Duration};
use serde_json::Value;
let end = Utc::now();
let start = end - Duration::days(99);
let response = client
.get_transfer_history("<email>")
// optional: get history from; default return the history with in 100 days
.with_start_time(start)
// optional: get history until; default is now.
.with_end_time(end)
// optional: default value: 1.
.with_page(2)
// optional: limit the amount of sub accounts; default 500.
.with_limit(100)
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn tranfer_sub_account<'a>(
&self,
from_email: &'a str,
to_email: &'a str,
asset: &'a str,
amount: f64,
) -> ParamBuilder<'a, '_, TransferSubAccountParams>
pub fn tranfer_sub_account<'a>( &self, from_email: &'a str, to_email: &'a str, asset: &'a str, amount: f64, ) -> ParamBuilder<'a, '_, TransferSubAccountParams>
Execute sub-account transfer.
§Example
use serde_json::Value;
let response = client
.tranfer_sub_account("<from_email>", "<to_email>", "BNB", 5.00)
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_sub_account_assets<'a>(
&self,
email: &'a str,
) -> ParamBuilder<'a, '_, SubAccountAssetParams>
pub fn get_sub_account_assets<'a>( &self, email: &'a str, ) -> ParamBuilder<'a, '_, SubAccountAssetParams>
Fetch sub-account assets.
§Example
use serde_json::Value;
let response = client
.get_sub_account_assets("<email>")
// optional: filter by symbol; gets all symbols by default.
.with_symbol("BNBUSDT")
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn dust_transfer<'a>(
&self,
asset: &'a str,
) -> ParamBuilder<'a, '_, DustTransferParams>
pub fn dust_transfer<'a>( &self, asset: &'a str, ) -> ParamBuilder<'a, '_, DustTransferParams>
Convert dust assets to BNB.
§Example
use serde_json::Value;
let response = client
// restricted to one asset at a time.
.dust_transfer("ETH")
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Sourcepub fn get_asset_dividends(&self) -> ParamBuilder<'_, '_, AssetDividendParams>
pub fn get_asset_dividends(&self) -> ParamBuilder<'_, '_, AssetDividendParams>
Query asset dividend record.
§Example
use chrono::{Utc, Duration};
use serde_json::Value;
let end = Utc::now();
let start = end - Duration::days(99);
let response = client
.get_asset_dividends()
// optional: filter by asset; gets all assets by default.
.with_asset("BNB")
// optional: get records from; gets recent records by default.
.with_start_time(start)
// optional: get records until; default is now.
.with_end_time(end)
// optional: processing time for request; default is 5000, can't be above 60000.
.with_recv_window(8000)
//
.json::<Value>()
.await?;Trait Implementations§
Source§impl Clone for WithdrawalClient
impl Clone for WithdrawalClient
Source§fn clone(&self) -> WithdrawalClient
fn clone(&self) -> WithdrawalClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WithdrawalClient
impl !RefUnwindSafe for WithdrawalClient
impl Send for WithdrawalClient
impl Sync for WithdrawalClient
impl Unpin for WithdrawalClient
impl !UnwindSafe for WithdrawalClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more