Skip to main content

Tools for working with Fantasy Premier League data

Project description

FPL data loader

Python package for loading and transforming data from the Fantasy Premier Leage API.

Usage

The package provides two main classes: FplApiData and get_element_summary.

The FplApiData class can be used to download all relevant data from the FPL API, including:

  • Players
  • Positions
  • Teams
  • Game weeks
  • Fixtures

To use the FplApiData class, first create an instance of the class:

from fpl_data.api import FplApiData

# make a request to the FPL API
api_data = FplApiData()

Then, you can access the data using the following attributes:

  • elements: A list of all players in the current season.
  • element_types: A list of all positions in the FPL game.
  • teams: A list of all teams in the Premier League.
  • events: A list of all game weeks in the current season.
  • fixtures: A list of all fixtures in the current season.

For example, to get the list of all players in the current season, you would do the following:

players = data.elements

The get_element_summary function can be used to get all past gameweek/season info for a given player_id.

To use the get_element_summary function, you need to pass the player_id as an argument:

summary = get_element_summary(player_id)

The summary object will contain the following information:

  • history: A list of all gameweek data for the current season.
  • history_past: A list of all gameweek data for past seasons.

For example, to get all past gameweek/season info for the player with ID 1, you would do the following:

summary = get_element_summary(1000)

The history attribute of the summary object will contain a list of dictionaries, each of which representing a gameweek. The dictionaries will contain the following keys:

  • gameweek: The gameweek number.
  • points: The number of points the player scored in the gameweek.
  • minutes: The number of minutes the player played in the gameweek.
  • goals_scored: The number of goals the player scored in the gameweek.
  • assists: The number of assists the player provided in the gameweek.
  • clean_sheets: The number of clean sheets the player kept in the gameweek.
  • bonus: The bonus points the player earned in the gameweek.
  • red_card: A boolean value indicating whether the player was sent off in the gameweek.

The history_past attribute of the summary object will contain a list of dictionaries, each of which representing a gameweek from a past season. The dictionaries will contain the same keys as the history attribute.


Local development

Make a virtual environment

cd fpl-data
conda env create -f environment.yml --prefix ./.env

Activate your environemt with:

conda activate ./.env

Create an editable install of the package

pip install --editable .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

FPL-data-loader-0.0.7.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FPL_data_loader-0.0.7-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file FPL-data-loader-0.0.7.tar.gz.

File metadata

  • Download URL: FPL-data-loader-0.0.7.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for FPL-data-loader-0.0.7.tar.gz
Algorithm Hash digest
SHA256 bc029a97e69121a32dc9e1026eae4b572ac6a866c9edba14da5b4102d832b75d
MD5 8b039b2fe8008f2d203e2a07f7d0670b
BLAKE2b-256 a41128d402571cc0af6977a5202a4fc200ec046fbfb9ef1d192cf84913e801af

See more details on using hashes here.

File details

Details for the file FPL_data_loader-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for FPL_data_loader-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 61b66e3c686d139020ba9ebe8af3fb8c2190c8a3e2a45f054d5f94fab78f5621
MD5 3bcd56fcf99bc7ab93fadfe425604666
BLAKE2b-256 ef5590e65695d62b7f7743ec185d83546d852656bebc0655a8ba3a296717eecf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page