A Python API for scraping football data from understat.com
Project description
jeke-understat-scrapper
A Python API for scraping football data from understat.com. Understat is a website with football data for 6 european leagues for every season since 2014/15 season. The leagues available are the Premier League, La Liga, Ligue 1, Serie A, Bundesliga and the Russian Premier League.
This is a maintained fork of understatapi with fixes for Understat's new AJAX-based data loading.
NOTE
This project is not affiliated with understat.com in any way
Installation
pip install jeke-understat-scrapper
Getting started
The API contains endpoints which reflect the structure of the understat website. Below is a table showing the different endpoints and the pages on understat.com to which they correspond
| Endpoint | Webpage |
|---|---|
| UnderstatClient.league | https://understat.com/league/<league_name> |
| UnderstatClient.team | https://understat.com/team/<team_name>/<season> |
| UnderstatClient.player | https://understat.com/player/<player_id> |
| UnderstatClient.match | https://understat.com/match/<match_id> |
Every method in the public API corresponds to one of the tables visible on the understat page for the relevant endpoint.
Each method returns JSON with the relevant data. Below are some examples of how to use the API. Note how the league() and team() methods can accept the names of leagues and teams respectively, but player() and match() must receive an id number.
from understatapi import UnderstatClient
understat = UnderstatClient()
# get data for every player playing in the Premier League in 2019/20
league_player_data = understat.league(league="EPL").get_player_data(season="2019")
# Get the name and id of one of the player
player_id, player_name = league_player_data[0]["id"], league_player_data[0]["player_name"]
# Get data for every shot this player has taken in a league match (for all seasons)
player_shot_data = understat.player(player=player_id).get_shot_data()
from understatapi import UnderstatClient
understat = UnderstatClient()
# get data for every league match involving Manchester United in 2019/20
team_match_data = understat.team(team="Manchester_United").get_match_data(season="2019")
# get the id for the first match of the season
match_id = team_match_data[0]["id"]
# get the rosters for the both teams in that match
roster_data = understat.match(match=match_id).get_roster_data()
You can also use the UnderstatClient class as a context manager which closes the session after it has been used, and also has some improved error handling. This is the recommended way to interact with the API.
from understatapi import UnderstatClient
with UnderstatClient() as understat:
team_match_data = understat.team(team="Manchester_United").get_match_data(season="2019")
Contributing
If you find any bugs in the code or have any feature requests, please make an issue and I'll try to address it as soon as possible.
Versioning
The versioning for this project follows the semantic versioning conventions.
Credits
This package is based on the original understatapi by collinb9.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jeke_understat_scrapper-1.0.1.tar.gz.
File metadata
- Download URL: jeke_understat_scrapper-1.0.1.tar.gz
- Upload date:
- Size: 538.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbb4fe063254b8623e4cdd55138eb489063d0f9379b9fdc5718168980ae936a6
|
|
| MD5 |
f78b6565d2d96b7e2340b332feebe79c
|
|
| BLAKE2b-256 |
2a2f744c997547f3c2d996c4e541f4542b84cd9ecd9895b8336bca1e127902b1
|
File details
Details for the file jeke_understat_scrapper-1.0.1-py3-none-any.whl.
File metadata
- Download URL: jeke_understat_scrapper-1.0.1-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b987864863f6346658405c0184a039b248346639019db33f071ca6be4bf26482
|
|
| MD5 |
2c9981f91c191daffee54886303b8fb0
|
|
| BLAKE2b-256 |
01f03ee7639d35d758429ba38e3a9c7553ce1196a93ef2f1245b92d54ec61fb8
|