JavaScript
Community maintained Node.js client for the topstats.gg API.
Welcome to the community maintained Node.js client for the Topstats.gg API.
npm install @topstats/sdkInitialize the Client
import { Client } from "@topstats/sdk";
const client = new Client("YOUR_TOKEN");Make Your First Request
// Get information about a bot
const bot = await client.getBot("583807014896140293");
console.log(bot.name, bot.server_count);Usage Examples
// Get detailed bot information
const bot = await client.getBot("583807014896140293");
console.log(bot.name, bot.server_count);API Reference
Methods
getBot(botId: string): Promise<BotData>
// Example
const bot = await client.getBot("583807014896140293");Response Types
interface BotData {
id: string;
name: string;
server_count: number;
monthly_votes: number;
total_votes: number;
// ... and more
}Error Handling
try {
await client.getBot("invalid-id");
} catch (error) {
if (error instanceof RateLimitError) {
console.log("Rate limited, try again later");
} else if (error instanceof TopStatsError) {
console.error("API Error:", error.message);
}
}Rate Limits
The API implements rate limiting to ensure fair usage. For detailed information about rate limits and best practices, please refer to our rate limit documentation.
top-stats/javascript-sdk
00