Guide
Rebuild a soccer league table from match results
Short answer: pull every final league match from StrikerAPI's list_games, award 3 points for a win and 1 for a draw, sort by points then your tiebreakers, and subtract any deductions. We matched get_standings exactly for five leagues in 2025-26, and for the 2023-24 Premier League and 2025-26 Championship once deductions were applied.
A league table looks trivial until a deduction or a tie on points appears. This guide builds the table, adds tiebreakers with head-to-head, and checks the result against the published standings. It is data engineering, not a forecast or a wager.
What each endpoint gives you
list_games costs 2 credits a call. With stage set to league, it returns the games that count toward the table: the regular season, the group stage or the league phase, without knockout rounds. Each game has the date, the status, the home and away team ids, names and scores, and a result of H, D or A. Add status set to final to skip fixtures not yet played. We used 200 games a page, and next_offset points at the next page. Seasons are named for the year they start, so 2025 is 2025-26. Several leagues, among them MLS and the NWSL, use the calendar year.
get_standings also costs 2 credits. It returns the published table: rank, played, wins, draws, losses, goals for and against, goal difference, points, deductions, home and away records and form. The response says the source is published.
So you can compute a table from scratch and compare it with a published one, row by row. The comparison is a good test of any pipeline that handles results.
Step 1: pull the matches and build the raw table
The functions below fetch every final league game for a league and season, build per-club totals and compute the head-to-head sub-table for a group of tied clubs. The helper retries on HTTP 429.
Set STRIKERAPI_API_KEY first. Premier League 2025 is two pages and 380 games, so the fetch costs 4 credits.
import json, os, time, urllib.error, urllib.request
import pandas as pd
KEY = os.environ["STRIKERAPI_API_KEY"]
def post(tool, body):
req = urllib.request.Request(f"https://mcp.strikerapi.com/v1/{tool}", data=json.dumps(body).encode(),
headers={"Content-Type": "application/json", "x-api-key": KEY})
for wait in (2, 5, 10, 20):
try:
with urllib.request.urlopen(req, timeout=90) as r:
return json.load(r)["data"]
except urllib.error.HTTPError as e:
if e.code != 429:
raise
time.sleep(wait)
def all_games(league, season):
games, offset = [], 0
while offset is not None:
page = post("list_games", {"league": league, "season": season, "stage": "league",
"status": "final", "limit": 200, "offset": offset})
games += page["games"]
offset = page.get("next_offset")
return games
def build_table(games, h2h_first=False):
rec = {}
for g in games:
h, a = g["home"], g["away"]
for t in (h, a):
rec.setdefault(t["team_id"], dict(name=t["name"], p=0, w=0, d=0, l=0, gf=0, ga=0))
hs, as_ = h["score"], a["score"]
for me, opp, gf, ga in ((h, a, hs, as_), (a, h, as_, hs)):
r = rec[me["team_id"]]
r["p"] += 1; r["gf"] += gf; r["ga"] += ga
r["w" if gf > ga else "d" if gf == ga else "l"] += 1
t = pd.DataFrame.from_dict(rec, orient="index")
t["gd"] = t.gf - t.ga
t["pts"] = 3 * t.w + t.d
return t
def head_to_head(games, ids):
"""Points, goal difference and goals scored in matches among the tied clubs only."""
mini = {i: [0, 0, 0] for i in ids}
for g in games:
h, a = g["home"]["team_id"], g["away"]["team_id"]
if h in mini and a in mini:
hs, as_ = g["home"]["score"], g["away"]["score"]
mini[h][0] += 3 if hs > as_ else 1 if hs == as_ else 0
mini[a][0] += 3 if as_ > hs else 1 if hs == as_ else 0
mini[h][1] += hs - as_; mini[a][1] += as_ - hs
mini[h][2] += hs; mini[a][2] += as_
return mini
def rank(table, games, h2h_first=False):
"""Sort by points, then either (goal difference, goals for, head to head) or (head to head, GD, GF)."""
table = table.copy()
table["key"] = list(zip(table.pts, table.gd, table.gf))
if h2h_first:
order = []
for pts, grp in table.groupby("pts", sort=False):
mini = head_to_head(games, set(grp.index)) if len(grp) > 1 else {}
for i in grp.index:
m = mini.get(i, [0, 0, 0])
order.append((i, (pts, m[0], m[1], m[2], table.gd[i], table.gf[i])))
order.sort(key=lambda x: x[1], reverse=True)
return [i for i, _ in order]
return list(table.sort_values(["pts", "gd", "gf"], ascending=False).index)A few details matter. Each match updates two clubs, so the loop updates the home and away record from one score pair. Points are 3 * wins + draws. Goal difference is goals for minus goals against. Teams are keyed by team_id, not by name, because names change.
The rank function supports two orderings. The default sorts on points, goal difference and goals scored. That is the rule in the Premier League, the Bundesliga and Ligue 1. With h2h_first set it groups clubs level on points, builds a mini table from the matches among them only, and sorts by head-to-head points, head-to-head goal difference and head-to-head goals before falling back to overall goal difference and goals scored. That is how La Liga and Serie A are decided. A full implementation would also need a rule for when head-to-head leaves a three-way tie still level, which this code resolves with the overall record instead of a repeated head-to-head round.
Step 2: compare with the published table
The second script runs five leagues for 2025-26, builds the table, calls get_standings, and reports any difference in points or rank. It also counts how many clubs were level on points and how many positions change if you flip the tiebreak rule.
import sys
from g6 import *
res = {}
for league, season, h2h in [("soccer", 2025, False), ("laliga", 2025, True), ("bundesliga", 2025, False), ("seriea", 2025, True), ("ligue1", 2025, False)]:
games = all_games(league, season)
t = build_table(games)
mine = rank(t, games, h2h)
st = post("get_standings", {"league": league, "season": season})
pub = st["standings"]
pub_order = [r["team_id"] for r in sorted(pub, key=lambda r: r["rank"])]
ded = [(r["display_name"], r["deductions"]) for r in pub if r["deductions"]]
pts_diff = [(r["display_name"], r["points"], int(t.pts[r["team_id"]])) for r in pub if r["points"] != t.pts[r["team_id"]]]
pos_diff = [(r["display_name"], r["rank"], mine.index(r["team_id"]) + 1) for r in pub if mine.index(r["team_id"]) + 1 != r["rank"]]
# tied-on-points groups
ties = t.groupby("pts").size(); ties = int((ties[ties > 1]).sum())
print(league, season, "games", len(games), "clubs", len(t), "source", st.get("source"), "| deductions", ded,
"| points differ", pts_diff, "| rank differ", pos_diff, "| clubs level on points", ties)
# does ignoring h2h choice change?
alt = rank(t, games, not h2h)
print(" other tiebreak rule changes", sum(1 for a, b in zip(mine, alt) if a != b), "positions")All five matched. In every league, the points were identical for every club and the ranks were identical for every club.
| League | Games | Clubs | Clubs level on points | Tiebreak used | Positions that change under the other rule |
|---|---|---|---|---|---|
| Premier League | 380 | 20 | 6 | goal difference first | 0 |
| La Liga | 380 | 20 | 8 | head-to-head first | 5 |
| Bundesliga | 306 | 18 | 6 | goal difference first | 0 |
| Serie A | 380 | 20 | 2 | head-to-head first | 2 |
| Ligue 1 | 305 | 18 | 4 | goal difference first | 0 |
The last column is the useful one. In the Premier League, Bundesliga and Ligue 1 the two rules give the same order, so a lazy implementation would never find out which one it needs. In La Liga, five positions depend on the rule, so a table built the wrong way would be wrong in five places and still look plausible. Ties on points are common, 10 to 40 percent of the clubs in each league, but in most cases goal difference separates them under both rules.
Ligue 1 returned 305 games, one fewer than the 306 that 18 clubs would play. The published table agrees with the rebuilt one on every club's games played and points, so the missing match is absent from both. We did not look into why.
Step 3: deductions
The 2025-26 tables above had no deductions. Others do. get_standings reports a deductions value for each club, and the published points already include it. In the 2023-24 Premier League, Everton lost 8 points and Nottingham Forest lost 4. In the 2025-26 Championship, Sheffield Wednesday lost 18, Leicester City 6 and West Bromwich Albion 2.
The last script rebuilds both tables twice, once ignoring deductions and once subtracting them, and compares each with the published ranks.
from g6 import *
for league, season in [("soccer", 2023), ("championship", 2025)]:
games = all_games(league, season)
t = build_table(games)
pub = {r["team_id"]: r for r in post("get_standings", {"league": league, "season": season})["standings"]}
t["ded"] = [pub[i]["deductions"] for i in t.index]
raw = rank(t, games) # ignores deductions
t2 = t.assign(pts=t.pts - t.ded)
adj = rank(t2, games)
pub_rank = {i: r["rank"] for i, r in pub.items()}
print(league, season, len(games), "games")
print(" published points match after deductions:", all(pub[i]["points"] == t2.pts[i] for i in t.index))
print(" raw rank differs from published:", [(t.name[i], pub_rank[i], raw.index(i) + 1) for i in t.index if raw.index(i) + 1 != pub_rank[i]])
print(" adjusted rank differs:", [(t.name[i], pub_rank[i], adj.index(i) + 1) for i in t.index if adj.index(i) + 1 != pub_rank[i]])
print(" deductions:", [(t.name[i], int(t.pts[i]), int(t.ded[i])) for i in t.index if t.ded[i]])The adjusted table matched the published one in both cases, and published points equalled raw points minus deductions for every club. The unadjusted table did not.
Raw and published points, with the deduction:
| Season | Club | Raw points | Deduction | Published points |
|---|---|---|---|---|
| Premier League 2023-24 | Everton | 48 | 8 | 40 |
| Premier League 2023-24 | Nottingham Forest | 36 | 4 | 32 |
| Championship 2025-26 | Sheffield Wednesday | 18 | 18 | 0 |
| Championship 2025-26 | West Bromwich Albion | 53 | 2 | 51 |
| Championship 2025-26 | Leicester City | 52 | 6 | 46 |
Where a table that ignores deductions puts clubs in the wrong place (published rank, then rank without deductions):
| Season | Club | Published rank | Rank if deductions ignored |
|---|---|---|---|
| Premier League 2023-24 | Everton | 15 | 12 |
| Premier League 2023-24 | Wolverhampton Wanderers | 14 | 15 |
| Premier League 2023-24 | Fulham | 13 | 14 |
| Premier League 2023-24 | AFC Bournemouth | 12 | 13 |
| Championship 2025-26 | West Bromwich Albion | 21 | 19 |
| Championship 2025-26 | Leicester City | 23 | 21 |
| Championship 2025-26 | Oxford United | 22 | 23 |
| Championship 2025-26 | Blackburn Rovers | 20 | 22 |
| Championship 2025-26 | Charlton Athletic | 19 | 20 |
Four Premier League clubs and five Championship clubs ended up in the wrong place without the deductions. Everton alone drops three places, and several Championship clubs shift by two, because a deduction of a few points moves a club past neighbours who are only a point or two away. Sheffield Wednesday's raw 18 points less 18 left it with zero.
Tables as of a date
The same code builds a table at any point in a season: filter the games by date before calling build_table. Call list_games with to set to a day, or filter the stored list on date. This is the reason to rebuild at all. get_standings gives the table as it stands for the season you ask for, with no date argument.
Limits
- Two tiebreak rules. We implemented points, goal difference, goals scored, and a head-to-head first variant. Real rules also include away goals in some leagues, fair play points and playoffs for titles or relegation. Check the league's own rulebook.
- Three-way ties. The head-to-head variant does not repeat the mini table after a partial split.
- Deductions come from the published table. The matches do not carry them, so a table rebuilt from results alone cannot know about a sanction.
- Five leagues for one season. The 100 percent match is for 2025-26 in five leagues, plus the 2023-24 Premier League and 2025-26 Championship. We did not test every league the API covers.
- Missing match in Ligue 1. One fewer game than a full round robin, present in both sources.
Live from the API
Free to embed on your own site, with no key needed. Get the embed code.
Get a free key Or download whole seasons as Parquet
Checked against the live API on 2026-12-06. Questions: hello@sportsdatahq.com.