Leaderboards API (BETA)

Competitive leaderboards with three security levels. Choose based on your game's requirements.


🟢 Simple Mode (Default - Casual Games)

Submit scores directly without tokens:

// One call - no token needed!
const result = await VenusAPI.leaderboard.submitScore({
  score: 1500,
  duration: 120,
  metadata: {
    levelCompleted: 10,
    powerUpsUsed: 3
  }
})

console.log(`Your rank: ${result.rank}`)

Minimal Configuration:

{
  "leaderboard": {
    "requiresToken": false
  }
}

Or just rely on defaults - server auto-resolves mode/period from config!

Security provided:

  • ✅ Score/duration bounds validation

  • ✅ Rate limiting (60 second cooldown per player)

  • ✅ Trust scores & shadow banning for repeat offenders

  • ❌ No session replay protection

  • ❌ No tamper protection

Best for: Simple integration


🟡 Token Mode (Competitive Games)

Add session validation for replay protection:

Configuration:

Additional security:

  • ✅ All simple mode security

  • ✅ Session validation (tokens expire in 1 hour)

  • ✅ Replay attack prevention (one-time use)

  • ✅ Mode locking (token locks game mode)

  • ❌ No tamper protection

Best for: Preventing replay attacks


🔴 Score Sealing Mode (High-Stakes Games)

Add cryptographic tamper protection:

Configuration:

Note: Hash computation is handled internally by the SDK using Web Crypto API (HMAC-SHA256). Games never need to implement cryptographic hashing manually. The hash always includes: score, duration, and token.

Maximum security:

  • ✅ All token mode security

  • ✅ Tamper-proof scores (HMAC-SHA256 verification)

  • ✅ Client-side cheat detection

  • ✅ Automatic hash computation (no crypto code needed in games)

Best for: Reduced hacking


Query Methods (Same for All Modes)

All query methods work identically regardless of security mode:

Note: Mode and period are automatically resolved from your config. For games with single mode/period, no need to specify them!


Advanced: Multiple Modes or Periods

For games with multiple leaderboards:

Config with multiple modes:

Explicitly specify mode in submissions/queries:

Same pattern for periods:


Configuration Reference

Minimal Config (Casual Games):

Uses defaults:

  • Single mode: "default"

  • Single period: "alltime" (permanent)

  • Basic rate limiting (30s between submissions)


Full Config (Advanced Games):

Smart Defaults:

  • If you configure only ONE mode/period, it's auto-selected (no need to specify in SDK calls)

  • If you configure MULTIPLE modes: defaults to "default" mode if present, otherwise first configured

  • If you configure MULTIPLE periods: defaults to "alltime" > "daily" > others (prefers permanent leaderboards)


Best Practices

  • Configure score bounds, durations, and anti-cheat settings in your game's config.json.

  • Use token or score-sealing modes for competitive or high-value rewards.

  • Log submissions and responses for customer support audits.

  • Treat this API as BETA; monitor release notes for schema or validation changes.

  • Seed leaderboards with NPC entries via seedEntries to avoid empty boards on launch.

  • UTC-based daily/weekly/monthly periods ensure global fairness; show countdowns using the Time API.


Features

  • Three Security Levels: Simple, Token, Sealed - choose based on game stakes

  • Multiple Modes: Support different game modes (classic, hard, etc.)

  • Time Periods: Daily, weekly, monthly, and all-time leaderboards

  • Anti-Cheat: Rate limiting, trust scores, shadow banning, optional session validation & sealing

  • Seed Entries: Pre-populate leaderboards with NPC scores

  • Pagination: Cursor-based pagination for large leaderboards

  • UTC-Based Periods: All players globally compete in same daily/weekly/monthly periods

Last updated