// Define constants
const API_URL: &str = "https://pro.circular.bot/market/cache";
const API_KEY: &str = "your-api-key"; // Replace with your API key
// Define the response structure
#[derive(Deserialize, Debug)]
struct MarketCacheResponse {
cached: String,
market_cache: Vec<MarketCacheEntry>,
}
#[derive(Deserialize, Debug)]
struct MarketCacheEntry {
pubkey: String,
owner: String,
params: Option<std::collections::HashMap<String, String>>, // Optional additional parameters
}
// Function to fetch the filtered market cache
async fn get_filtered_market_cache() -> 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));
// Define tokens as a comma-separated string
let tokens = vec![
"So11111111111111111111111111111111111111112",
"BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
"6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
]
.join(",");
// Set up query parameters
let query_params = [("onlyjup", "false"), ("tokens", &tokens)];
// Send the GET request
let response = client
.get(API_URL)
.headers(headers)
.query(&query_params)
.send()
.await?;
if response.status().is_success() {
let market_cache: MarketCacheResponse = response.json().await?;
println!("Market-Cache: {:#?}", market_cache);
} 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_filtered_market_cache().await {
eprintln!("An error occurred: {}", err);
}
}