Metadata-Version: 2.4
Name: footballcharts
Version: 0.1.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/developers
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,api,pandas,sports analytics,fbref alternative,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).

```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 2020 | 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()` | finished matches: date, kickoff (UTC), teams, score, half-time score, first-goal minute; `home_xg`/`away_xg` on a paid plan | free |
| `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 model's probabilities: `p_home`, `p_draw`, `p_away`, over/under, both teams to score, expected goals | 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 and shot data cover 66 leagues from the 2022 season onwards. Matches the provider has no statistics for are `NaN` in `read_schedule()` and left out of `read_team_match_stats()`.

## 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 three forms:
- a Football Charts key (`"premier"`, `"cha"`, `"germany3"`, `"usa1"`, `"wengland1"`);
- 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>.

## License

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