Examples
// Define constants
const API_URL = 'https://pro.circular.bot/market/cache';
const API_KEY = 'your-api-key'; // Replace by your API Key
const requestOptions = {
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY,
},
params: {
onlyjup: false,
tokens: [
"So11111111111111111111111111111111111111112",
"BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
"6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
].join(',')
},
};
const getFilteredMarketCache = async () => {
try {
const response = await axios.get(API_URL, requestOptions);
console.log('Market-Cache: ', response?.data);
} catch (error) {
console.log('Error: ', error?.response?.data);
}
};
getFilteredMarketCache();
// Define constants
const API_URL: string = 'https://pro.circular.bot/market/cache';
const API_KEY: string = 'your-api-key'; // Replace with your API key
// Define the request options interface
interface RequestOptions {
headers: {
'Content-Type': string;
'x-api-key': string;
};
params: {
onlyjup: boolean;
tokens: string; // Comma-separated string of tokens
};
}
// Define response structure (adjust based on actual API response)
interface MarketCacheResponse {
cached: string;
market_cache: Array<{
pubkey: string;
owner: string;
params?: Record<string, string>; // Optional additional parameters
}>;
}
// Request options
const requestOptions: RequestOptions = {
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY,
},
params: {
onlyjup: false,
tokens: [
"So11111111111111111111111111111111111111112",
"BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
"6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
].join(','), // Join tokens into a comma-separated string
},
};
// Function to fetch the filtered market cache
const getFilteredMarketCache = async (): Promise<void> => {
try {
const response: AxiosResponse<MarketCacheResponse> = await axios.get(API_URL, requestOptions);
console.log('Market-Cache: ', response.data);
} catch (error: any) {
console.error('Error: ', error?.response?.data || error.message);
}
};
// Execute the function
getFilteredMarketCache();
# Define constants
API_URL = "https://pro.circular.bot/market/cache"
API_KEY = "your-api-key" # Replace with your API key
# Request options
headers = {
"Content-Type": "application/json",
"x-api-key": API_KEY,
}
tokens = [
"So11111111111111111111111111111111111111112",
"BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
"6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
]
params = {
"onlyjup": False,
"tokens": ",".join(tokens), # Join tokens into a comma-separated string
}
# Function to fetch filtered market cache
def get_filtered_market_cache():
try:
response = requests.get(API_URL, headers=headers, params=params)
response.raise_for_status() # Raise an exception for HTTP errors
print("Market-Cache:", response.json())
except requests.exceptions.RequestException as error:
print("Error:", error.response.json() if error.response else str(error))
# Execute the function
get_filtered_market_cache()
// 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);
}
}
Last updated