SUNBOT

Leaderboard API

A small, public, read-only API, so your server's economy can show up outside Discord: a game server, a stream overlay, your community site. A plain GET, no keys.

PRIVACY FIRSTIt's opt-in per server. A server that hasn't turned it on answers a plain 404, the same as a server that doesn't exist, so nothing can be scraped. No user ids, no avatars, no changes: a display name and public stats.

Turning it on

  1. Dashboard → Config → Public leaderboard, or /admin → Economy → Public leaderboard.
  2. It shows your board's address and the API address, with your server id in it (the guild below).
  3. Turn it off any time and the API goes back to 404 for your server.

The same switch gives you a page anyone can open without signing in: sunbotapp.com/leaderboard?g=<server id>.

The endpoint

GET https://sunbotapp.com/api/leaderboard

No authentication and Access-Control-Allow-Origin: *, so a browser can call it directly. Answers are cached for 45 seconds and requests are rate-limited per IP.

ParameterValuesMeaning
guild (required)a server idYour Discord server's id.
typemoney · level · activityWhat to sort by: net worth (the default), XP level, or this week's messages. richest and cash mean money; weekly means activity.
limit1 to 50How many players. 25 by default.

An example

curl "https://sunbotapp.com/api/leaderboard?guild=123456789012345678&type=money&limit=3"
{
  "guild": "123456789012345678",
  "type": "money",
  "updatedAt": 1724990000000,
  "count": 3,
  "entries": [
    { "rank": 1, "name": "Mike",  "net": 2340000, "level": 42, "activity": 1234, "streak": 14 },
    { "rank": 2, "name": "Elena", "net": 1980500, "level": 39, "activity":  980, "streak":  7 },
    { "rank": 3, "name": "Denis", "net": 1750000, "level": 44, "activity": 1510, "streak": 21 }
  ]
}

In type, activity comes back as weekly.

The fields

FieldTypeMeaning
ranknumberThe place, from 1, for the type asked.
namestringThe display name, up to 32 characters. Never a user id.
netnumberNet worth: cash and bank.
levelnumberXP level.
activitynumberMessages this week.
streaknumberThe daily bonus streak.

Errors

StatusBodyWhen
400{"error":"missing_guild"}No guild.
404{"error":"not_found"}The server hasn't turned it on, or doesn't exist.
429{"error":"rate_limited"}Too many requests from your IP: wait and cache.

What people build with it

// in a browser or Node: the top 3 by net worth
const r = await fetch('https://sunbotapp.com/api/leaderboard?guild=YOUR_ID&limit=3');
if (r.ok) {
  const { entries } = await r.json();
  for (const e of entries) console.log(`#${e.rank} ${e.name}: ${e.net.toLocaleString()}`);
}

A write API?

Today it only reads. An API that changes balances from outside Discord, so a purchase in your game could spend SunBot coins, needs per-server keys, scoped permissions and the same care as every other money path, so it will be a deliberate step. If you'd use it, tell us what for: DM the bot or email iwannahelp@sunbotapp.com.