SDKCookbook
Read a leaderboard
Read a board, a wallet's rank outside the top, every page of a board, and a referrer's earnings.
The boards are public: no key and no signer. Each answer's entries are in data, and you is the wallet's own entry, even outside the top, or null when it has none.
const { data, error } = await bnc.api.GET('/v1/leaderboards/wallets', {
params: { query: { timeframe: 'month', limit: 10, wallet } },
})
if (error) throw new Error(error.detail ?? error.title)
for (const entry of data.data) console.log(entry.rank, entry.wallet, entry.reclaimedLamports)
console.log(data.you ? `Rank ${data.you.rank}` : 'Not on the board', `as of ${data.asOf}`)Show asOf with a board: it's when the snapshot was computed. paginate follows nextCursor to the end of a board:
const burners = paginate(async (cursor) => {
const page = await bnc.api.GET('/v1/leaderboards/burners', {
params: { query: { timeframe: 'all', limit: 200, cursor } },
})
if (page.error) throw new Error(page.error.detail ?? page.error.title)
return page.data
})
for await (const burner of burners) console.log(burner.rank, burner.slug, burner.raisedLamports)What a referrer earned comes from the payout ledger, paid and missed apart:
const { data, error } = await bnc.api.GET('/v1/referrers/{codeOrAddress}/earnings', {
params: { path: { codeOrAddress }, query: { timeframe: 'month' } },
})
if (error) throw new Error(error.detail ?? error.title)
console.log(BigInt(data.paidLamports), BigInt(data.missedLamports))Leaderboards and stats lists every board, its timeframes and how fresh it is.