// Define constants
const API_URL: &str = "https://pro.circular.bot/market/status";
const API_KEY: &str = "your-api-key"; // Replace with your API Key
// Define the response structure
#[derive(Deserialize, Debug)]
struct MarketStatusResponse {
status: String,
details: Option<serde_json::Value>, // Adjust based on the actual response structure
}
// Function to fetch market status
async fn get_market_status() -> Result<(), Box<dyn std::error::Error>> {
// Create a client
let client = reqwest::Client::new();
// Set up headers
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers.insert("x-api-key", HeaderValue::from_static(API_KEY));
// Send the GET request
let response = client
.get(API_URL)
.headers(headers)
.send()
.await?;
if response.status().is_success() {
let market_status: MarketStatusResponse = response.json().await?;
println!("Market-Cache: {:#?}", market_status);
} else {
eprintln!(
"Error: {}",
response.text().await.unwrap_or_else(|_| "Unknown error".to_string())
);
}
Ok(())
}
// Main function
#[tokio::main]
async fn main() {
if let Err(err) = get_market_status().await {
eprintln!("An error occurred: {}", err);
}
}