pub struct Credentials {
pub api_key: String,
pub api_secret: String,
}Expand description
Gate.io API Credentials.
Communication with Gate.io API authenticated endpoints requires valid API credentials. These credentials are used for HMAC SHA-512 signing of requests to ensure authenticity.
Note: Production and testnet API credentials are not interchangeable. Make sure to use the appropriate credentials for your environment.
Fields§
§api_key: StringAPI key for authentication
api_secret: StringAPI secret for HMAC signing
Implementations§
Source§impl Credentials
impl Credentials
Sourcepub fn new(api_key: impl Into<String>, api_secret: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>, api_secret: impl Into<String>) -> Self
Creates new API credentials
Examples found in repository?
examples/sync/get_open_orders.rs (line 9)
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_open_orders().page(1).limit(100);
14
15 let resp = client.send(req)?;
16 let body = resp.into_body_str()?;
17 let resp_obj: Value = serde_json::from_str(&body).unwrap();
18 println!("{:?}", resp_obj);
19
20 Ok(())
21}More examples
examples/sync/get_currencies.rs (line 9)
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 // Get all available currencies
14 let req = spot::get_currencies();
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!("{:?}", resp_obj);
20
21 Ok(())
22}examples/sync/get_currency_pairs.rs (line 9)
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 // Get all available currency pairs
14 let req = spot::get_currency_pairs();
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!("{:?}", resp_obj);
20
21 Ok(())
22}examples/sync/get_currency.rs (line 9)
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 // Get details for a specific currency
14 let req = spot::get_currency("BTC");
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!("{:?}", resp_obj);
20
21 Ok(())
22}examples/sync/get_currency_pair.rs (line 9)
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 // Get details for a specific currency pair
14 let req = spot::get_currency_pair("BTC_USDT");
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!("{:?}", resp_obj);
20
21 Ok(())
22}examples/sync/get_orderbook.rs (line 9)
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 // Get orderbook for BTC_USDT
14 let req = spot::get_orderbook("BTC_USDT").limit(100).interval("0");
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!("{:?}", resp_obj);
20
21 Ok(())
22}Additional examples can be found in:
- examples/sync/get_account_book.rs
- examples/sync/get_my_trades.rs
- examples/sync/get_price_orders.rs
- examples/sync/get_candlesticks.rs
- examples/sync/get_batch_user_fee.rs
- examples/sync/cancel_order.rs
- examples/sync/get_orders.rs
- examples/sync/get_market_trades.rs
- examples/sync/get_order.rs
- examples/sync/amend_order.rs
- examples/sync/get_price_order.rs
- examples/sync/get_insurance_history.rs
- examples/sync/get_account.rs
- examples/sync/get_ticker.rs
- examples/sync/create_order.rs
- examples/sync/create_batch_orders.rs
- examples/sync/cancel_all_price_orders.rs
- examples/sync/cancel_price_order.rs
- examples/sync/amend_batch_orders.rs
- examples/sync/cancel_all_open_orders.rs
- examples/sync/cancel_batch_orders.rs
- examples/sync/get_fee.rs
- examples/sync/countdown_cancel_all.rs
- examples/sync/create_cross_liquidate_orders.rs
- examples/sync/create_price_order.rs
- examples/sync_example.rs
Trait Implementations§
Source§impl Clone for Credentials
impl Clone for Credentials
Source§fn clone(&self) -> Credentials
fn clone(&self) -> Credentials
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Credentials
impl Debug for Credentials
impl Eq for Credentials
Source§impl PartialEq for Credentials
impl PartialEq for Credentials
impl StructuralPartialEq for Credentials
Auto Trait Implementations§
impl Freeze for Credentials
impl RefUnwindSafe for Credentials
impl Send for Credentials
impl Sync for Credentials
impl Unpin for Credentials
impl UnsafeUnpin for Credentials
impl UnwindSafe for Credentials
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