get_account/
get_account.rs1use gateio_rs::{api::spot, http::Credentials, ureq::GateHttpClient};
2use serde_json::Value;
3
4fn main() -> Result<(), Box<gateio_rs::ureq::Error>> {
5 dotenv::dotenv().ok();
6
7 let api_key = std::env::var("GATE_API_KEY").expect("GATE_API_KEY not set");
8 let api_secret = std::env::var("GATE_API_SECRET").expect("GATE_API_SECRET not set");
9 let credentials = Credentials::new(api_key, api_secret);
10
11 let client = GateHttpClient::default().credentials(credentials.clone());
12
13 let req = spot::get_account();
15
16 let resp = client.send(req)?;
17 let body = resp.into_body_str()?;
18 let resp_obj: Value = serde_json::from_str(&body).unwrap();
19 println!("All account balances: {:?}", resp_obj);
20
21 let req = spot::get_account().currency("USDT");
23
24 let resp = client.send(req)?;
25 let body = resp.into_body_str()?;
26 let resp_obj: Value = serde_json::from_str(&body).unwrap();
27 println!("USDT balance: {:?}", resp_obj);
28
29 Ok(())
30}