https://github.com/top-gg-community/node-sdk
An official module for interacting with the Top.gg API
https://github.com/top-gg-community/node-sdk
api bot discord javascript list
Last synced: 7 months ago
JSON representation
An official module for interacting with the Top.gg API
- Host: GitHub
- URL: https://github.com/top-gg-community/node-sdk
- Owner: Top-gg-Community
- Created: 2018-02-10T17:33:32.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-18T22:00:21.000Z (11 months ago)
- Last Synced: 2025-07-01T10:06:21.271Z (7 months ago)
- Topics: api, bot, discord, javascript, list
- Language: TypeScript
- Homepage: https://topgg.js.org/
- Size: 128 KB
- Stars: 136
- Watchers: 13
- Forks: 43
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Top.gg Node SDK
An official module for interacting with the Top.gg API
# Installation
`yarn add @top-gg/sdk` or `npm i @top-gg/sdk`
# Introduction
The base client is Topgg.Api, and it takes your Top.gg token and provides you with plenty of methods to interact with the API.
See [this tutorial](https://github.com/top-gg/rust-sdk/assets/60427892/d2df5bd3-bc48-464c-b878-a04121727bff) on how to retrieve your API token.
You can also setup webhooks via Topgg.Webhook, look down below at the examples for how to do so!
# Links
[Documentation](https://topgg.js.org)
[API Reference](https://docs.top.gg) | [GitHub](https://github.com/top-gg/node-sdk) | [NPM](https://npmjs.com/package/@top-gg/sdk) | [Discord Server](https://discord.gg/EYHTgJX)
# Popular Examples
## Auto-Posting stats
If you're looking for an easy way to post your bot's stats (server count, shard count), check out [`topgg-autoposter`](https://npmjs.com/package/topgg-autoposter)
```js
const client = Discord.Client(); // Your discord.js client or any other
const { AutoPoster } = require("topgg-autoposter");
AutoPoster("topgg-token", client).on("posted", () => {
console.log("Posted stats to Top.gg!");
});
```
With this your server count and shard count will be posted to Top.gg
## Webhook server
```js
const express = require("express");
const Topgg = require("@top-gg/sdk");
const app = express(); // Your express app
const webhook = new Topgg.Webhook("topggauth123"); // add your Top.gg webhook authorization (not bot token)
app.post(
"/dblwebhook",
webhook.listener((vote) => {
// vote is your vote object
console.log(vote.user); // 221221226561929217
})
); // attach the middleware
app.listen(3000); // your port
```
With this example, your webhook dashboard (`https://top.gg/bot/{your bot's id}/webhooks`) should look like this:
