Skip to main content
Get up and running with the Premier League library in under 5 minutes.

Installation

Install the library using pip:
pip install premier_league
The library automatically initializes a local SQLite database on first use.

Your first queries

1

Fetch league standings

Get the current Premier League table:
from premier_league import RankingTable

# Get current season standings
ranking = RankingTable()
standings = ranking.get_ranking_list()

# Display top 5 teams
print(standings[0])  # Header row
for team in standings[1:6]:
    print(team)
Output:
['Position', 'Team', 'MP', 'W', 'D', 'L', 'GF', 'GA', 'GD', 'Points']
['1', 'Manchester City', '38', '32', '4', '2', '102', '31', '71', '100']
['2', 'Arsenal', '38', '28', '5', '5', '88', '43', '45', '89']
...
2

Query player statistics

Get the top goalscorers:
from premier_league import PlayerSeasonLeaders

# Get top 10 goalscorers
scorers = PlayerSeasonLeaders(stat_type='G')
top_scorers = scorers.get_top_stats_list(limit=10)

# Display results
for player in top_scorers[1:]:  # Skip header
    print(f"{player[0]} ({player[2]}): {player[3]} goals")
Output:
Erling Haaland (Manchester City): 36 goals
Harry Kane (Tottenham Hotspur): 30 goals
Ivan Toney (Brentford): 20 goals
...
3

Access match statistics

Get detailed match data for analysis:
from premier_league import MatchStatistics
from datetime import datetime

# Initialize match statistics
stats = MatchStatistics()

# Get Arsenal's recent games
arsenal_games = stats.get_team_games("Arsenal")

# Get games before a specific date
recent_games = stats.get_games_before_date(
    date=datetime(2024, 2, 1),
    limit=5,
    team="Liverpool"
)

print(f"Found {len(arsenal_games)} Arsenal games")
4

Check transfer activity

View player transfers for a team:
from premier_league import Transfers

# Initialize transfers for current season
transfers = Transfers()

# Get Chelsea's incoming transfers
chelsea_ins = transfers.transfer_in_table("Chelsea")

# Display transfers
print(chelsea_ins[0])  # Header
for transfer in chelsea_ins[1:]:
    print(transfer)

Multi-league support

The library supports data from multiple European leagues:
from premier_league import RankingTable

ranking = RankingTable(league="Premier League")
standings = ranking.get_ranking_list()

Export data

All modules support exporting data in multiple formats:
from premier_league import RankingTable, PlayerSeasonLeaders

# Export standings to CSV
ranking = RankingTable()
ranking.get_ranking_csv("standings_2024", header="Premier League 2023-24")

# Export top scorers to JSON
scorers = PlayerSeasonLeaders(stat_type='G')
scorers.get_top_stats_json("top_scorers", header="Goals_2024")

# Export to PDF (requires premier_league[pdf])
ranking.get_ranking_pdf("standings_2024")

Update data

Keep your local database current with the latest matches:
from premier_league import MatchStatistics

stats = MatchStatistics()

# Update with latest match data
stats.update_data_set()
The update_data_set() method takes considerable time due to rate limiting (4 seconds between requests) to respect data source restrictions.

Next steps

Core modules

Explore MatchStatistics, RankingTable, PlayerSeasonLeaders, and Transfers

Machine learning

Create ML-ready datasets with lag-based features

Flask API

Deploy as a REST API with rate limiting and caching

Data export

Export data to CSV, JSON, and PDF formats

Build docs developers (and LLMs) love