|
1 | | -## API Usage |
| 1 | +# API Usage |
| 2 | + |
| 3 | +## Games |
2 | 4 |
|
3 | 5 | ### List Game Metadata |
4 | 6 |
|
@@ -40,8 +42,7 @@ curl "https://api.openfront.io/public/games?start=2025-10-25T00:00:00Z&end=2025- |
40 | 42 | "type": "Singleplayer", |
41 | 43 | "mode": "Free For All", |
42 | 44 | "difficulty": "Medium" |
43 | | - }, |
44 | | - ... |
| 45 | + } |
45 | 46 | ] |
46 | 47 | ``` |
47 | 48 |
|
@@ -75,7 +76,7 @@ curl "https://api.openfront.io/public/game/ABSgwin6?turns=false" |
75 | 76 |
|
76 | 77 | **Note:** Public player IDs are stripped from game records for privacy. |
77 | 78 |
|
78 | | ---- |
| 79 | +## Players |
79 | 80 |
|
80 | 81 | ### Get Player Info |
81 | 82 |
|
@@ -108,3 +109,100 @@ GET https://api.openfront.io/public/player/:playerId/sessions |
108 | 109 | ```bash |
109 | 110 | curl "https://api.openfront.io/public/player/HabCsQYR/sessions" |
110 | 111 | ``` |
| 112 | + |
| 113 | +## Clans |
| 114 | + |
| 115 | +### Clan Leaderboard |
| 116 | + |
| 117 | +Shows the top 100 clans by `weighted wins`. |
| 118 | + |
| 119 | +**Endpoint:** |
| 120 | + |
| 121 | +``` |
| 122 | +GET https://api.openfront.io/public/clans/leaderboard |
| 123 | +``` |
| 124 | + |
| 125 | +Weighted wins have a half-life of 30 days to favor recent wins. |
| 126 | + |
| 127 | +Weighted wins are calculated using the following formula: |
| 128 | + |
| 129 | +``` |
| 130 | +FUNCTION calculateScore(session: ClanSession, decay: NUMBER = 1) → NUMBER |
| 131 | + // 1. Calculate average team size |
| 132 | + avgTeamSize ← session.totalPlayerCount ÷ session.numTeams |
| 133 | +
|
| 134 | + // 2. Determine how much the clan contributed to their team |
| 135 | + // (clan players divided by average players per team) |
| 136 | + clanMemberRatio ← session.clanPlayerCount ÷ avgTeamSize |
| 137 | +
|
| 138 | + // 3. Apply decay factor (e.g., for older sessions) |
| 139 | + weightedValue ← clanMemberRatio × decay |
| 140 | +
|
| 141 | + // 4. Calculate match difficulty based on number of teams |
| 142 | + // More teams → harder to win → higher reward for victory |
| 143 | + // Uses square root to avoid extreme scaling |
| 144 | + difficulty ← MAX(1, √(session.numTeams - 1)) |
| 145 | +
|
| 146 | + // 5. Return final score: |
| 147 | + // - Win: reward is multiplied by difficulty |
| 148 | + // - Loss: penalty is divided by difficulty (less punishment in harder matches) |
| 149 | + IF session.hasWon THEN |
| 150 | + RETURN weightedValue × difficulty |
| 151 | + ELSE |
| 152 | + RETURN weightedValue ÷ difficulty |
| 153 | + END IF |
| 154 | +END FUNCTION |
| 155 | +``` |
| 156 | + |
| 157 | +### Clan stats |
| 158 | + |
| 159 | +Displays comprehensive clan performance statistics for a specified clan over a chosen time range. If no time range is provided, it shows lifetime stats (starting from early November 2025). |
| 160 | + |
| 161 | +Key metrics include: |
| 162 | + |
| 163 | +- Total games, wins, losses, and win rate |
| 164 | +- Win/loss ratio and weighted win/loss ratio\* broken down by: |
| 165 | + - Team type (e.g., 2 teams, 3 teams, duos, trios, etc) |
| 166 | + - Number of teams in the game (2 teams, 5 teams, 20 teams, etc) |
| 167 | + |
| 168 | +**Note:** No decay is used, so weighted wins will be different from in the leaderboard. |
| 169 | + |
| 170 | +**Endpoint** |
| 171 | + |
| 172 | +``` |
| 173 | +GET https://openfront.io/public/clan/:clanTag |
| 174 | +``` |
| 175 | + |
| 176 | +**Query Parameters:** |
| 177 | + |
| 178 | +- `start` (optional): ISO 8601 timestamp |
| 179 | +- `end` (optonal): ISO 8601 timestamp |
| 180 | + |
| 181 | +**Example** |
| 182 | + |
| 183 | +```bash |
| 184 | +curl https://api.openfront.io/public/clan/UN?start=2025-11-15T00:00:00Z & |
| 185 | +end=2025-11-18T23:59:59Z |
| 186 | +``` |
| 187 | + |
| 188 | +### Clan Sessions |
| 189 | + |
| 190 | +A clan session is created any time a player with that clan tag is in a public team game. If no start or end query parameter is provided, lifetime sessions (starting early November 2025) are shown. |
| 191 | + |
| 192 | +**Endpoint** |
| 193 | + |
| 194 | +``` |
| 195 | +GET https://api.openfront.io/public/clan/:clanTag/sessions |
| 196 | +``` |
| 197 | + |
| 198 | +**Query Parameters:** |
| 199 | + |
| 200 | +- `start` (optional): ISO 8601 timestamp |
| 201 | +- `end` (optonal): ISO 8601 timestamp |
| 202 | + |
| 203 | +**Example** |
| 204 | + |
| 205 | +```bash |
| 206 | +curl https://api.openfront.io/public/clan/UN/sessions?start=2025-11-15T00:00:00Z & |
| 207 | +end=2025-11-18T23:59:59Z |
| 208 | +``` |
0 commit comments