Crates.io | swapspace-api |
lib.rs | swapspace-api |
version | 0.1.0 |
source | src |
created_at | 2024-07-16 13:17:24.999305 |
updated_at | 2024-07-16 13:17:24.999305 |
description | Swapspace API client |
homepage | |
repository | https://github.com/jeizsm/swapspace-api |
max_upload_size | |
id | 1305018 |
size | 30,398 |
use swapspace_api::SwapSpaceApi;
let api = SwapSpaceApi::new("api_key".to_string()).expect("failed to create client");
or set SWAPSPACE_API_KEY env variable and call default
use swapspace_api::SwapSpaceApi;
let api = SwapSpaceApi::default();
let api = SwapSpaceApi::default();
api.get_currencies().await.unwrap();
let api = SwapSpaceApi::default();
let amounts = GetAmounts {
from_currency: "btc".to_string(),
from_network: "btc".to_string(),
to_currency: "eth".to_string(),
to_network: "eth".to_string(),
amount: 0.1,
partner: None,
fixed: false,
float: false,
};
let response = api.get_amounts(&amounts).await.unwrap();
let api = SwapSpaceApi::default();
let amounts = GetAmounts {
from_currency: "btc".to_string(),
from_network: "btc".to_string(),
to_currency: "eth".to_string(),
to_network: "eth".to_string(),
amount: 0.1,
partner: None,
fixed: false,
float: false,
};
let response = api.get_amounts_best(&amounts).await.unwrap();
let api = SwapSpaceApi::default();
let response = api.get_partners().await.unwrap();
let api = SwapSpaceApi::default();
let data = ExchangeRequest {
partner: "simpleswap".to_string(),
from_currency: "btc".to_string(),
from_network: "btc".to_string(),
to_currency: "eth".to_string(),
to_network: "eth".to_string(),
address: Address("0x32be343b94f860124dc4fee278fdcbd38c102d88".to_string()),
amount: 2.0,
fixed: true,
extra_id: "".to_string(),
rate_id: "".to_string(),
user_ip: "8.8.8.8".to_string(),
refund: Address("1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX".to_string()),
};
let response = api.post_exchange(data).await.unwrap();
let api = SwapSpaceApi::default();
let id = "id";
let response = api.get_exchange_status(id).await.unwrap();