Skip to content
datasportsAPI

03Fantasy & games

Score your fantasy game on real match ratings.

Fantasy points need the same inputs every round: who played, how well, and how that compares across the season. Ratings, season totals, form lines and leaderboards come straight from the API, so your scoring rules are the only thing you write.

The play

Four calls. Final whistle: round scored.

Each marker is a request. Each run carries its ids to the next.

read it left to right
  1. 1

    Who played, and how well

    Both lineups with formations, substitutes and missing players, and every player's match rating and match statistics.

    GETLineups: /v2/fixtures/{id}/lineupsAll plans
  2. 2

    The season behind the score

    A player's totals and averages in one league season: appearances, minutes, goals, expected goals, passes, duels and average rating.

    GETPlayer season statistics: /v2/players/{id}/statisticsAll plans
  3. 3

    Draw the form line

    On Pro, every match rating a player earned across a league season, oldest first, with the opponent of each match. Ready to plot.

    GETSeason ratings: /v2/players/{id}/ratingsPro + Business
  4. 4

    Rank the leaders

    On Pro, the season's leaderboards per statistic (rating, goals, assists, saves and more), paged, or a single board when you only need one.

    GETTop players: /v2/leagues/{id}/top-playersPro + Business

In code

Ratings in, points out

Turn each player's match rating into fantasy points, then pull the season and the leaderboard for context.

Install
pip install datasportsapi
Key
export DATASPORTSAPI_API_KEY=dsa_live_…
All SDKs and the CLI
from datasportsapi import DataSportsAPI

client = DataSportsAPI()  # reads DATASPORTSAPI_API_KEY

lineups = client.fixtures.lineups(fixture_id)["data"]
points = {}
for side in (lineups["home"], lineups["away"]):
    for p in side["players"]:
        if p["rating"] is not None:
            points[p["player"]["id"]] = round(p["rating"] * 10)

season = client.players.statistics(player_id, league=league_id, season=season_id)

# Pro: the season's best-rated players
leaders = client.leagues.top_players(league_id, season=season_id,
                                     category="averageRating", limit=10)

Field notes

Worth knowing before launch.

  1. Ratings are the source's 0 to 10 match ratings. A player without one has rating null, so score that case on purpose.

  2. Ask one leaderboard with category= rather than every board at once: a far smaller response.

  3. Player and team ids are ours and stay the same across seasons, so rosters never need remapping.

Which plan

Goes live on Pro.

Ratings inside lineups and season statistics work on every plan, but form lines and leaderboards are premium endpoints. Pro also keeps six months of history, enough to re-score the recent rounds of a season.

  1. Free

    01

    $0/ month

    1,000 requests / day

    Wire up your scoring against last week's matches.

  2. Starter

    02

    $49/ month

    250,000 requests / month

    A private league scored from lineups and season totals, with 30 days of history.

  3. Fits this play

    Pro

    03

    $199/ month

    1,000,000 requests / month

    Form lines, leaderboards and team of the week, with six months of history.

  4. Business

    04

    $999/ month

    10,000,000 requests / month

    Past seasons from the full history, and a webhook the moment lineups are announced.

Score last weekend's round on a free key.

1,000 free requests a day during the beta. No card, no sales call.