Metadata-Version: 2.4
Name: footballcharts
Version: 0.2.0
Summary: Football (soccer) data for 98 leagues as pandas DataFrames: results with half-time scores and goal minutes, xG and match statistics, tables, fixtures with calibrated model probabilities and live scores, from the Football Charts API.
Author-email: Football Charts <contact@football-charts.com>
License-Expression: MIT
Project-URL: Homepage, https://www.football-charts.com/developers
Project-URL: Documentation, https://www.football-charts.com/python
Project-URL: API reference, https://www.football-charts.com/llms-full.txt
Project-URL: Pricing, https://www.football-charts.com/developers#pricing
Project-URL: Open dataset (CC BY 4.0), https://doi.org/10.5281/zenodo.22295583
Keywords: football,soccer,football data,soccer data,xg,expected goals,closing odds,dixon-coles,api,pandas,sports analytics,fbref alternative,football-data.co.uk,soccerdata
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25
Requires-Dist: pandas>=1.3
Dynamic: license-file

# footballcharts

Football (soccer) data for **98 leagues in 44 countries**, lower divisions and five women's leagues included, as pandas DataFrames: results with half-time scores and goal minutes, **xG and per-match statistics**, league tables, fixtures with **calibrated model probabilities**, season projections and **live scores**.

This is the Python client for the [Football Charts API](https://www.football-charts.com/developers). Guide with examples: <https://www.football-charts.com/python>

```bash
pip install footballcharts
```

## Quick start (no key needed)

```python
from footballcharts import FootballCharts

fc = FootballCharts(leagues="ENG-Premier League", seasons=2025)   # the 2025-2026 season
schedule = fc.read_schedule()      # one row per match: scores, half-time, first goal minute
table = fc.read_league_table()

upcoming = FootballCharts(leagues=["premier", "germany3", "wengland1"]).read_fixtures()
upcoming[["home_team", "away_team", "p_home", "p_draw", "p_away", "p_over_2_5"]]
```

Without a key you get 25 requests a day per IP: enough to try it. Each league and season you read costs one request, and answers are cached for the life of the `FootballCharts` object.

## Keys and limits

| Access | Requests a day | Seasons | xG & match statistics | Live scores |
|---|---|---|---|---|
| No key | 25 per IP | current and previous | no | no |
| Free key | 200 (100 until the email is confirmed) | current and previous | no | no |
| Paid plan | 5,000 (Personal) or 25,000 (Commercial) | every season back to 2015 (excl. 2019–20) | yes | yes |

Plans and prices: <https://www.football-charts.com/developers#pricing>

Get a free key from Python. It is in the answer at once and arrives by email with a confirmation link:

```python
from footballcharts import register_key
register_key("you@example.com", use="model")
```

Then set it once for every script:

```bash
export FOOTBALLCHARTS_API_KEY=fc_...
```

or pass it: `FootballCharts(..., api_key="fc_...")`.

## What you can read

| Method | Rows | Key |
|---|---|---|
| `read_leagues()` | every league: key, name, country, seasons held | none |
| `read_seasons()` | seasons held for the chosen leagues | none |
| `read_schedule(include_odds=False)` | finished matches: date, kickoff (UTC), teams, score, half-time score, first-goal minute; `home_xg`/`away_xg` on a paid plan; pass `include_odds=True` for the 17 market-average closing-odds columns | free (xG & odds: paid) |
| `read_closing_odds()` | market-average closing odds per finished match: 1X2, over/under 2.5 & 3.5, BTTS, half-time 1X2 & O/U 0.5/1.5, plus `odds_timing` (`close` or `pre_match`) | paid |
| `read_football_data(include_fc_extras=True)` | drop-in `football-data.co.uk` column schema (`Div`, `Date`, `Time`, `HomeTeam`, `AwayTeam`, `FTHG`, `FTAG`, `FTR`, `HTHG`, `HTAG`, `HTR`, plus paid stats `HS..AR`, `AvgH/D/A`, `Avg>2.5/<2.5`, and optional `HomeXG`/`AwayXG`) | free (stats & odds: paid) |
| `read_team_match_stats()` | one row per team and match: goals for and against, xG and xG against, shots, shots on target, possession, passes, corners, offsides, fouls, cards, saves | paid |
| `read_fixtures()` | the next few days with the published model's probabilities, the same numbers as the API's fixtures CSV: `p_home`, `p_draw`, `p_away`, over/under, both teams to score, expected goals; `dc_base_*` columns hold the plain Dixon-Coles baseline | free |
| `read_league_table(view="classic")` | standings; `view="luck"` adds expected points and position, `view="goals"` goal records | free |
| `read_goal_timing()` | when each team scores and concedes, in 15-minute bins | free |
| `read_projection()` | Monte Carlo projection of the final table: title, top-4 and relegation chances | free |
| `read_live()` | matches in play: minute, score, half-time score, pre-match probabilities (updated every 10 s) | paid |

xG covers 64 leagues from 2022 on, and shots 67 leagues, some back to 2015 (counted 29 Nov 2026; league by league at <https://www.football-charts.com/match-statistics>). Matches the provider has no statistics for are `NaN` in `read_schedule()` and left out of `read_team_match_stats()`.

## Closing odds & migrating from `football-data.co.uk`

On a paid plan, `/results/` returns the market-average closing odds of each finished match: 1X2, over/under 2.5 and 3.5, both teams to score, and the half-time lines (17 columns in all). Read them directly through the package:

```python
from footballcharts import FootballCharts

fc = FootballCharts(leagues="E0", seasons="2425", api_key="fc_your_key")
odds = fc.read_closing_odds()                    # 17 odds_* columns indexed by [league, season, game]
sched = fc.read_schedule(include_odds=True)      # schedule + xG + closing odds in one cached call
```

Migrating an existing `football-data.co.uk` pipeline takes **one line** — all 36 `football-data.co.uk` division codes (`E0`–`EC`, `SC0`–`SC3`, `D1`/`D2`, `I1`/`I2`, `SP1`/`SP2`, `F1`/`F2`, `N1`, `B1`, `P1`, `T1`, `G1`, `AUT`, `BRA`, `JPN`, `USA`, ...) plus all 62 additional Football Charts leagues work out of the box:

```python
# before
import pandas as pd
df = pd.read_csv("https://www.football-data.co.uk/mmz4281/2425/E0.csv")

# after (exact Div/Date/HomeTeam/AwayTeam/FTHG/FTAG/FTR/HS..AR/AvgH/AvgD/AvgA schema + HomeXG/AwayXG)
import footballcharts as fc
df = fc.read_football_data("E0", "2425")
```

Pass `include_fc_extras=False` for only the classic 28 `football-data.co.uk` columns. Coverage market by market: <https://www.football-charts.com/closing-odds>

## Coming from soccerdata or FBref

The readers follow [soccerdata](https://github.com/probberechts/soccerdata)'s conventions:
- the index `[league, season, game]`, with `game` as `"YYYY-MM-DD Home-Away"`;
- league ids like `"ENG-Premier League"` or `"GER-Bundesliga"`;
- the columns `home_score` / `away_score`, `home_xg` / `away_xg`.

Most code moves over by changing the reader:

```python
# before
import soccerdata as sd
schedule = sd.FBref(leagues="ENG-Premier League", seasons="2025-2026").read_schedule()

# after
from footballcharts import FootballCharts
schedule = FootballCharts(leagues="ENG-Premier League", seasons="2025-2026").read_schedule()
```

## Leagues and seasons

**Leagues** take any of four forms:
- a Football Charts key (`"premier"`, `"cha"`, `"germany3"`, `"usa1"`, `"wengland1"`);
- a `football-data.co.uk` division code (`"E0"`, `"E1"`, `"D1"`, `"SP1"`, `"I1"`, `"BRA"`, `"JPN"`);
- a soccerdata-style id (`"ENG-Championship"`, `"NED-Eredivisie"`);
- a unique name (`"Eredivisie"`).

`FootballCharts().read_leagues()` lists all 98 with their keys.

**Seasons** take `2025`, `"2025-2026"`, `"2025-26"`, `"25/26"` or `"2526"`, a year meaning the season that starts in it. Calendar-year leagues (MLS, Brazil, Japan, Scandinavia, ...) take the year: `seasons=2025`. Leave `seasons` out for the latest season with data.

## The low-level client

```python
from footballcharts import Client

api = Client()                                   # or Client("fc_...")
api.results("premier", season="2025-2026")       # the API's JSON as a dict
api.match("england/premier-league/2026-11-28-arsenal-vs-chelsea")
api.track_record(days=90)                        # every published prediction, settled
api.key_status()                                 # tier and daily limit, uses no quota
```

## Errors

Every error is a `FootballChartsError`, and its message says what to do next:
- `SeasonNotAvailable`: a season outside your key's window;
- `PaidPlanRequired`: statistics or live scores on a free key;
- `RateLimitError`: the daily or per-minute limit, with `.retry_after` in seconds when the API sends one;
- `AuthenticationError`: a missing, unknown or disabled key;
- `NotFound`: no such league, team or match.

Server errors and dropped connections are retried twice.

## Attribution and terms

- **Credit:** show "Data by football-charts.com" with a link. Every DataFrame carries `df.attrs["attribution"]` and `df.attrs["source_url"]`.
- **Use:** free keys are for personal use. Apps, sites, bots and channels need the Commercial plan.
- **The model:** its probabilities are a calibrated statistical baseline that does not beat the betting market, and they are not betting advice. Every published prediction is settled in public at <https://www.football-charts.com/track-record>.

## Also available

- **Open dataset:** 76,991 matches with every goal minute, CC BY 4.0, [doi:10.5281/zenodo.22295583](https://doi.org/10.5281/zenodo.22295583).
- **MCP server for AI assistants:** `https://mcp.football-charts.com/mcp` (no key needed to try).
- **API reference in one file:** <https://www.football-charts.com/llms-full.txt>.

## Changes

- **0.2.0:** Added native closing-odds readers (`read_closing_odds()`, `read_schedule(include_odds=True)`), 1-line `football-data.co.uk` schema drop-in (`read_football_data()`), and all 36 `football-data.co.uk` division codes (`E0`, `D1`, `SP1`, `BRA`, ...) in `resolve_league()`.
- **0.1.1:** `read_fixtures()` gives the published model's probabilities in the plain columns (`p_home`, ...), the same numbers as the API's fixtures CSV; the plain Dixon-Coles baseline moved to `dc_base_*` columns. In 0.1.0 the plain columns held the baseline.

## License

The client code is MIT licensed. The data is governed by the Football Charts API terms.
