# Historical Odds Scraper: Closing Lines, Opening Odds & Results (`keelwright/historical-odds-scraper`) Actor

Historical betting odds for any Flashscore league and season: opening and closing moneyline, 1X2, spread and total from up to 20 bookmakers per country, with scores and results. Soccer, NBA, NFL, MLB, NHL, tennis.

- **URL**: https://apify.com/keelwright/historical-odds-scraper.md
- **Developed by:** [Keelwright](https://apify.com/keelwright) (community)
- **Categories:** Sports, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 game with main markets

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Historical Odds Scraper: closing lines, opening odds and results

Download historical betting odds for any league and season on Flashscore: soccer, NBA, NFL, MLB, NHL, tennis tournaments and 13 more sports. Every finished game comes with each bookmaker's **opening and closing prices** for the moneyline, three-way (1X2), spread and total, the final score, and how each market settled (won, lost, push or half).

- Whole seasons in one run. Paste a league page, pick the seasons, and get every game of each season, newest first.
- Opening and closing prices per bookmaker, plus the average, best price and no-vig chances at the close, and the opening average for the moneyline and 1X2.
- Results included. Each market says which side won, so you can backtest without joining a second dataset.
- Deep history. Premier League odds go back to 2003/2004; most big leagues have ten or more seasons.
- Up to 20 bookmakers per country, such as bet365, William Hill, Betfair and Ladbrokes in the UK. US sportsbooks (DraftKings, FanDuel, BetMGM) are there for recent seasons.
- Every market on request: alternate lines, halves, quarters, both teams to score, correct score and more, each price with its result.

### What can I use historical odds for?

- **Backtesting betting models**: test a model or a staking plan on real closing prices and real results.
- **Closing line value (CLV)**: compare the price you took with the closing line, game by game.
- **Model training**: opening and closing implied probabilities as features or as a benchmark for your own ratings.
- **Market research**: how margins, favourites and line movement differ between bookmakers, leagues and seasons.
- **Sports journalism and content**: how often favourites won, which teams beat the market, upsets of the season.

### How to download historical odds

1. Click **Try for free**.
2. In **Leagues**, paste one or more league pages from flashscore.com, for example `https://www.flashscore.com/football/england/premier-league/` or `https://www.flashscore.com/basketball/usa/nba/`.
3. Pick the seasons: type them in **Seasons** (`2023/2024`, or `2023` for MLB and tennis tournaments), or set **Number of seasons** to get the latest ones.
4. Pick the **bookmaker regions**. *United Kingdom* has the most bookmakers and the longest history; a US state adds DraftKings, FanDuel and BetMGM for recent seasons.
5. Click **Start** and download the results as JSON, CSV, Excel or HTML, or read them through the API.

You can also paste a season's own page (`…/premier-league-2015-2016/`) to get just that season, and narrow a run with **Teams or players**, **From date** and **To date**.

### Input example

```json
{
    "leagues": [
        "https://www.flashscore.com/football/england/premier-league/",
        "https://www.flashscore.com/football/spain/laliga/"
    ],
    "seasons": ["2024/2025", "2023/2024"],
    "regions": ["GB"],
    "maxItems": 2000
}
```

### Which leagues, seasons and bookmakers?

Any league or tournament page on flashscore.com works: soccer leagues and cups in every country, the NBA, NFL, MLB, NHL and college leagues, EuroLeague, ATP and WTA tournaments, and the other sports Flashscore covers (MMA, cricket, darts, handball, rugby, volleyball, esports and more). Tennis seasons are per tournament, so paste each tournament you need (`https://www.flashscore.com/tennis/atp-singles/wimbledon/`).

How far back the odds go depends on the league. The Premier League has odds from 2003/2004 with 4 to 5 bookmakers at first, about 10 from 2007/2008 and about 20 today. Smaller leagues often start later. Games that Flashscore has no odds for are skipped and not charged; the run summary counts them as `gamesWithoutOdds`.

Bookmakers come from the regions you pick (31 in all, the same list as Flashscore's odds comparison): four US states (New Jersey, New York, Virginia, Massachusetts), Ontario, the United Kingdom, Ireland, Australia and 23 more countries in Europe, Latin America, Africa and Asia. Each region adds its bookmakers and one request per game.

UK bookmakers have the longest history: an NBA game from 2023/2024 has 11 of them. US sportsbooks are recent on Flashscore: New Jersey has DraftKings, FanDuel, BetMGM, Fanatics and bet365 for the 2026/2027 NBA season, but only bet365 and BetMGM for 2024/2025 and only bet365 for 2023/2024.

### What data do you get?

Every row is one game.

| Field                       | What it holds                                                                                                                           |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `matchId`, `url`            | Flashscore game id and link                                                                                                             |
| `sport`                     | `soccer`, `basketball`, `american-football`, `baseball`, `hockey`, `tennis` and so on                                                   |
| `competition`               | League name with stage (*NBA - Play Offs*), country, id and link                                                                        |
| `season`, `round`           | Season as Flashscore names it (`2023/2024`) and the round or stage (*Round 38*, *Final*)                                                |
| `startTime`                 | Start time (ISO 8601, UTC)                                                                                                              |
| `status`, `statusDetail`    | Always `finished`; the detail says *After Overtime*, *After Penalties* and so on                                                        |
| `home`, `away`              | Team or player name, short code, Flashscore id, link and logo                                                                           |
| `score`, `winner`           | Final score and the winner: `home`, `away` or `draw` (penalties and shootouts count)                                                    |
| `regions`, `bookmakerCount` | The regions asked for and how many bookmakers priced the game                                                                           |
| `moneyline`, `threeWay`     | Closing best price per side and its bookmaker, closing average, fair chances, margin, opening average and fair chances, and `result`    |
| `spread`, `total`           | The main line most bookmakers closed at, with best and average closing prices and `result` at that line                                 |
| `bookmakers`                | One entry per bookmaker: closing and opening moneyline, 1X2, its own spread and total line with prices                                  |
| `markets`                   | With **All markets**: every price listed, one entry per price with market, period, selection, line, closing and opening price, `result` |
| `scrapedAt`                 | When the row was made                                                                                                                   |

`result` gives each side's settlement: `won`, `lost`, `push` (stake returned), `half-won` or `half-lost` (quarter lines such as -0.75). `period` says what part of the game a market covers: `full-time` (regulation time, as for 1X2 bets), `full-time-incl-overtime` (how US sportsbooks settle the moneyline, spread and total), `first-half` and so on. Prices are decimal odds by default; set **Odds format** to *American* for `-110` style odds.

#### Output example

Arsenal against Everton on the last day of the 2023/2024 Premier League, with UK bookmakers (bookmaker list shortened with "…"):

```json
{
    "matchId": "jXP8f29S",
    "url": "https://www.flashscore.com/match/football/jXP8f29S/",
    "sport": "soccer",
    "competition": {
        "name": "Premier League",
        "country": "England",
        "id": "dYlOSQOD",
        "url": "https://www.flashscore.com/football/england/premier-league/"
    },
    "season": "2023/2024",
    "round": "Round 38",
    "startTime": "2024-05-19T15:00:00.000Z",
    "status": "finished",
    "statusDetail": "Finished",
    "home": {
        "name": "Arsenal",
        "shortCode": "ARS",
        "id": "hA1Zm19f",
        "url": "https://www.flashscore.com/team/arsenal/hA1Zm19f/",
        "logoUrl": "https://static.flashscore.com/res/image/data/0n1ffK6k-vcNAdtF9.png"
    },
    "away": {
        "name": "Everton",
        "shortCode": "EVE",
        "id": "KluSTr9s",
        "url": "https://www.flashscore.com/team/everton/KluSTr9s/",
        "logoUrl": "https://static.flashscore.com/res/image/data/EBfZuwme-bRmKmISE.png"
    },
    "score": {
        "home": 2,
        "away": 1
    },
    "winner": "home",
    "regions": ["GB"],
    "bookmakerCount": 10,
    "moneyline": null,
    "threeWay": {
        "period": "full-time",
        "best": {
            "home": {
                "odds": 1.22,
                "bookmaker": "bet365"
            },
            "draw": {
                "odds": 7.5,
                "bookmaker": "bet365"
            },
            "away": {
                "odds": 14,
                "bookmaker": "BetUK"
            }
        },
        "average": {
            "home": 1.206,
            "draw": 7.111,
            "away": 11.778
        },
        "fairProbability": {
            "home": 0.7862,
            "draw": 0.1333,
            "away": 0.0805
        },
        "margin": 0.0547,
        "arbitrage": null,
        "bookmakers": 9,
        "openingAverage": {
            "home": 1.166,
            "draw": 7.3,
            "away": 15.5
        },
        "openingFairProbability": {
            "home": 0.8097,
            "draw": 0.1293,
            "away": 0.0609
        },
        "result": {
            "home": "won",
            "draw": "lost",
            "away": "lost"
        }
    },
    "spread": {
        "period": "full-time",
        "line": -2,
        "best": {
            "home": {
                "odds": 2.04,
                "bookmaker": "bet365"
            },
            "away": {
                "odds": 1.89,
                "bookmaker": "bet365"
            }
        },
        "average": {
            "home": 1.97,
            "away": 1.847
        },
        "arbitrage": null,
        "bookmakers": 3,
        "result": {
            "home": "lost",
            "away": "won"
        }
    },
    "total": {
        "period": "full-time",
        "line": 3.5,
        "best": {
            "over": {
                "odds": 1.98,
                "bookmaker": "BetUK"
            },
            "under": {
                "odds": 1.91,
                "bookmaker": "bet365"
            }
        },
        "average": {
            "over": 1.908,
            "under": 1.841
        },
        "arbitrage": null,
        "bookmakers": 8,
        "result": {
            "over": "lost",
            "under": "won"
        }
    },
    "bookmakers": [
        {
            "bookmaker": "bet365",
            "region": "GB",
            "moneylineHome": null,
            "moneylineAway": null,
            "moneylineHomeOpening": null,
            "moneylineAwayOpening": null,
            "threeWayHome": 1.22,
            "threeWayDraw": 7.5,
            "threeWayAway": 10,
            "threeWayHomeOpening": 1.2,
            "threeWayDrawOpening": 6.5,
            "threeWayAwayOpening": 13,
            "spreadLine": -2,
            "spreadHome": 2.04,
            "spreadAway": 1.89,
            "spreadHomeOpening": 1.83,
            "spreadAwayOpening": 2.07,
            "totalLine": 3.5,
            "over": 1.91,
            "under": 1.91,
            "overOpening": 1.91,
            "underOpening": 1.91
        },
        "…"
    ],
    "scrapedAt": "2026-11-20T09:40:00.000Z"
}
```

With **All markets** on, `markets` lists every price, for example:

```json
[
    {
        "bookmaker": "bet365",
        "market": "total",
        "period": "full-time",
        "selection": "over",
        "line": 3.25,
        "odds": 1.85,
        "opening": 1.84,
        "active": false,
        "result": "half-lost"
    },
    "…"
]
```

The Output tab has two table views: **Games** (one row per game with the averages and results) and **Bookmakers** (one row per game and bookmaker).

### How much does it cost?

You pay only for the games you get (pay per event); Apify platform usage is included.

| What                                       | Price                 |
| ------------------------------------------ | --------------------- |
| Game with the main markets                 | $4.00 per 1,000 games |
| Game with all markets (**All markets** on) | $8.00 per 1,000 games |
| Run start                                  | $0.05 per 1,000 runs  |

Examples:

- One Premier League season (380 games): about **$1.52**.
- Ten Premier League seasons (3,800 games): about **$15.20**.
- One NBA season with pre-season and play-offs (1,377 games in 2023/2024): about **$5.51**.
- Wimbledon 2023 men's singles with qualifying (239 matches): about **$0.96**.

Games without odds are skipped and not charged. You can cap any run with **Max games** or with the maximum cost per run in the run options; the run stops cleanly at the limit. Apify's free plan includes $5 of monthly credit, enough for about 1,200 games.

### Tips

- **Newest first.** Seasons come in the order you list them (newest first with **Number of seasons**), and games in each season from the last to the first, so a small **Max games** gives you the latest games.
- **Dates are in UTC.** **From date** and **To date** filter by the game's start day.
- **The current season counts.** With **Number of seasons** 1 you get the current season so far; before a new season starts, you get the last one.
- **More bookmakers.** Add regions to compare more bookmakers; the UK alone has about 20 for big soccer leagues today. For US sports, *United Kingdom* gives more bookmakers than a US state for seasons before 2026.
- **Season names.** Use the names from the league's archive on Flashscore: `2023/2024` for most leagues, `2023` for leagues played in one calendar year (MLB, MLS, Brazilian Serie A) and for tennis tournaments. If a season isn't found, the run log lists the league's seasons.
- **Integrations.** Send results to Google Sheets, a database or your own webhook with Apify [integrations](https://apify.com/integrations), or call the Actor through the [API](https://docs.apify.com/api/v2).

### FAQ

**Where do the odds come from?**
From Flashscore's odds comparison, which keeps the prices bookmakers listed for each game after it ends. The Actor reads each season's results list and then the odds of each game in the regions you pick.

**What exactly is the closing price here?**
The last price each bookmaker listed before it took the game off its board. For most games and bookmakers that is the pre-game closing line. The opening price is the first price Flashscore recorded for that bookmaker.

**What does `active: false` mean?**
The bookmaker had taken that price down before the end (for example after a goal). Best and average closing prices use only prices that were still offered; the opening averages and results use all of them.

**Is the result from the bookmakers?**
The `result` of each price is how Flashscore settled it from the final score, using the market's own rules (regulation time for 1X2, overtime included for US moneylines). `winner` is the winner of the game.

**Do I need a proxy?**
No. Flashscore answers Apify's servers directly. The proxy option is there in case that changes.

**Is it legal to scrape betting odds?**
This Actor collects publicly listed sports data: fixtures, scores and the odds bookmakers published. It does not log in or collect private information. Check the source's terms and your local laws for your use case, especially for commercial use.

**Something is missing or broken?**
Open an issue in the **Issues** tab with the run link, and it will be looked at.

*Historical Odds Scraper is an independent tool. It is not affiliated with, endorsed by or connected to Flashscore, Livesport s.r.o. or any bookmaker; bookmaker names are trademarks of their owners. Odds are shown for information only and are not betting advice. If you bet, do it responsibly and only where it is legal for you.*

# Actor input Schema

## `leagues` (type: `array`):

League or tournament pages from flashscore.com, for example https://www.flashscore.com/football/england/premier-league/ or https://www.flashscore.com/basketball/usa/nba/. A season's page (…/premier-league-2023-2024/) gives that season only.

## `seasons` (type: `array`):

Seasons as Flashscore names them: 2023/2024 for most leagues, 2023 for MLB and tennis tournaments (2023-24 and 23/24 work too). Leave empty to use "Number of seasons".

## `seasonCount` (type: `integer`):

Used when "Seasons" is empty: the latest seasons with results, newest first. 1 is the current season so far (or the last one, before a new season starts).

## `dateFrom` (type: `string`):

Only games on or after this day (UTC), for example 2024-01-01.

## `dateTo` (type: `string`):

Only games on or before this day (UTC).

## `teams` (type: `array`):

Only games of these teams or players, for example Arsenal, Lakers or Alcaraz. Leave empty for all.

## `regions` (type: `array`):

Bookmakers that Flashscore shows to visitors from these places (up to 10). Each region adds its bookmakers and one request per game; a bookmaker found in several regions is listed once. The United Kingdom has the most bookmakers and the longest history (about 20 today). US states add DraftKings, FanDuel and BetMGM for recent seasons only.

## `bookmakers` (type: `array`):

Only these bookmakers, for example DraftKings, FanDuel or bet365 (bet365 matches every bet365 site). Leave empty for all bookmakers in the chosen regions.

## `markets` (type: `string`):

Main markets: moneyline, three-way (1X2), spread and total for each bookmaker, with opening and closing prices and results. All markets adds every other price the bookmakers listed (alternate lines, halves, quarters, double chance, both teams to score, correct score and more), one entry per price with how it settled.

## `oddsFormat` (type: `string`):

Decimal (1.91) or American (-110) odds.

## `maxItems` (type: `integer`):

Stop after this many games. 0 means no limit.

## `maxConcurrency` (type: `integer`):

How many games to load at the same time.

## `proxyConfiguration` (type: `object`):

Not needed: Flashscore answers Apify's servers directly. Turn on only if requests start failing.

## Actor input object example

```json
{
  "leagues": [
    "https://www.flashscore.com/football/england/premier-league/"
  ],
  "seasons": [],
  "seasonCount": 1,
  "teams": [],
  "regions": [
    "GB"
  ],
  "bookmakers": [],
  "markets": "main",
  "oddsFormat": "decimal",
  "maxItems": 20,
  "maxConcurrency": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `games` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "leagues": [
        "https://www.flashscore.com/football/england/premier-league/"
    ],
    "regions": [
        "GB"
    ],
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("keelwright/historical-odds-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "leagues": ["https://www.flashscore.com/football/england/premier-league/"],
    "regions": ["GB"],
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("keelwright/historical-odds-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "leagues": [
    "https://www.flashscore.com/football/england/premier-league/"
  ],
  "regions": [
    "GB"
  ],
  "maxItems": 20
}' |
apify call keelwright/historical-odds-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,keelwright/historical-odds-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/lTtUyidpqTvFgUgUM/builds/RgNEi4NtMbBetsdKL/openapi.json
