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.5.tar.gz (4.2 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.5-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: FPL-data-loader-0.0.5.tar.gz
  • Upload date:
  • Size: 4.2 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.5.tar.gz
Algorithm Hash digest
SHA256 8c3cff59b42bc58c917da307cfd80737b4b486d9e4436466f0a30960ff796634
MD5 b87ca51ec7f092730a99916ef93709a0
BLAKE2b-256 7fa6f16fd640ae6a8e03910c03280b6bc8c2f2ceb6a4ead23a40cf6fe3cb5eb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for FPL_data_loader-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 79aa079f96c728589620fcb45f88a4f61f49cd9ef00af9df18bba1dd627745b3
MD5 e0a467185666868cebcfd3769b30d8c8
BLAKE2b-256 d9a14ae35ff6874ce8a0cd9bc9c84dbae2fbe2ee595bffbd8ef6fe570023d649

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