// Sample integration for Copin API
async function getLeaderboardData() {
// API endpoint to fetch the leaderboard data
const url = "https://api.copin.io/leaderboards/page";
// Copin-provided API key (replace with your actual key)
const apiKey = "YOUR_COPIN_API_KEY";
// Request headers with authentication
const headers = {
"X-API-KEY": apiKey,
Accept: "application/json",
};
// Query parameters (customizable based on your needs)
const params = new URLSearchParams({
protocol: "GMX", // GMX v1 on Arbitrum
queryDate: "1741408905620", // March 2025
statisticType: "MONTH", // Monthly leaderboard
offset: "0", // Starting record
limit: "10", // Number of results
sort_by: "ranking",
sort_type: "asc", // Sort ranking increase
});
try {
// Make the API request
const response = await fetch(`${url}?${params}`, {
method: "GET",
headers: headers,
});
// Check if the response is successful
if (!response.ok) {
throw new Error(
`HTTP Error: ${response.status} - ${response.statusText}`
);
}
// Parse the JSON response
const data = await response.json();
// Log or process the data
console.log("Copin Leaderboard Data:", data);
return data;
} catch (error) {
// Handle errors (e.g., network issues, rate limits, invalid key)
console.error("Error fetching leaderboard data:", error.message);
if (error.message.includes("429")) {
console.error("Rate limit exceeded. Check your quota.");
}
}
}
// Execute the function
getLeaderboardData();