Examples
// Define constants
const API_URL = 'https://pro.circular.bot/market/status';
const API_KEY = 'your-api-key'; // Replace by your API Key
const requestOptions = {
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY,
}
};
const getMarketStatus = async () => {
try {
const response = await axios.get(API_URL, requestOptions);
console.log('Market-Cache: ', response?.data);
} catch (error) {
console.log('Error: ', error?.response?.data);
}
};
getMarketStatus();
// Define constants
const API_URL: string = 'https://pro.circular.bot/market/status';
const API_KEY: string = 'your-api-key'; // Replace with your API Key
// Define the request options interface
interface RequestOptions extends AxiosRequestConfig {
headers: {
'Content-Type': string;
'x-api-key': string;
};
}
// Request options
const requestOptions: RequestOptions = {
headers: {
'Content-Type': 'application/json',
'x-api-key': API_KEY,
},
};
// Define the response structure (adjust as needed)
interface MarketStatusResponse {
status: string;
details: Record<string, any>; // Adjust to match the structure of the API response
}
// Function to fetch market status
const getMarketStatus = async (): Promise<void> => {
try {
const response: AxiosResponse<MarketStatusResponse> = 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
getMarketStatus();
# Define constants
API_URL = "https://pro.circular.bot/market/status"
API_KEY = "your-api-key" # Replace with your API key
# Request headers
headers = {
"Content-Type": "application/json",
"x-api-key": API_KEY,
}
# Function to fetch market status
def get_market_status():
try:
response = requests.get(API_URL, headers=headers)
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_market_status()
// 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);
}
}
Last updated