home products documents terms contact shop (coming soon!)

Web API Integration

Sync ranked battle data to your external website.

Display live ranked data on your community website. Leaderboards, usage statistics, player rankings — all synced automatically.


Quick Setup

Step 1: Enable API Sync

Edit config/cobbleranked/api.yaml:

enabled: true

endpoint:
  baseUrl: "https://your-website.com/api"

auth:
  apiKey: "your-secret-key-here"

Step 2: Create API Endpoint

Your website needs endpoints to receive the data:

app.post('/api/usage-stats', (req, res) => {
  const data = req.body;
  // Store data (database, cache, file)
  res.json({ success: true });
});

app.post('/api/leaderboard', (req, res) => {
  const data = req.body;
  res.json({ success: true });
});

Step 3: Test

Run /rankedadmin api test in-game to verify connection.


Data Format

Usage Stats

Endpoint: POST {baseUrl}/usage-stats

{
  "serverId": "battle-server-1",
  "seasonName": "Season 1",
  "timestamp": "2026-01-02T12:00:00Z",
  "formats": {
    "SINGLES": {
      "tiers": {
        "1500+": {
          "minElo": 1500,
          "maxElo": null,
          "totalBattles": 1250,
          "species": [
            {
              "name": "Garchomp",
              "usagePercent": 45.2,
              "abilities": { "Rough Skin": 85.3 },
              "items": { "Choice Scarf": 42.1 },
              "moves": { "Earthquake": 98.2 }
            }
          ]
        }
      }
    }
  }
}

Leaderboard

Endpoint: POST {baseUrl}/leaderboard

{
  "serverId": "battle-server-1",
  "seasonName": "Season 1",
  "timestamp": "2026-01-02T12:00:00Z",
  "formats": {
    "SINGLES": {
      "players": [
        {
          "rank": 1,
          "uuid": "550e8400-...",
          "playerName": "ChampionPlayer",
          "elo": 2150,
          "tier": "CHERISH",
          "wins": 245,
          "losses": 32,
          "winRate": 88.45
        }
      ]
    }
  }
}

Configuration

SettingDescription
enabledEnable API sync
endpoint.baseUrlYour API base URL
auth.apiKeySecret key sent in X-API-Key header
sync.intervalMinutesHow often to sync (default: 60)
sync.dataTypes.usageStatsSend usage statistics
sync.dataTypes.leaderboardSend leaderboard data
sync.push.enabledEnable pushing data to external API
sync.push.onlyIfChangedOnly sync when data changes
http.timeoutSecondsRequest timeout (default: 30)
http.retryAttemptsNumber of retries on failure
Full Configuration
enabled: true

endpoint:
  baseUrl: "https://your-website.com/api"

auth:
  apiKey: "your-secret-key-here"

sync:
  intervalMinutes: 60
  dataTypes:
    usageStats: true
    leaderboard: true
  push:
    enabled: true
    onlyIfChanged: true
  pull:
    enabled: false

http:
  timeoutSeconds: 30
  retryAttempts: 3
  retryDelaySeconds: 5

Authentication

HeaderValue
Content-Typeapplication/json
X-API-KeyYour configured API key

Validate X-API-Key on your server before processing data.


Commands

CommandDescription
/rankedadmin api syncForce immediate sync
/rankedadmin api statusView sync status
/rankedadmin api testTest configuration

See Also