This project provides a Python library for retrieving and analyzing Fantasy Premier League (FPL) data. The library allows users to fetch detailed information about a FPL manager's performance, their leagues, and their gameweek statistics.
To use the pyPL library, clone the repository and install the necessary dependencies.
git clone https://github.com/RickyKimani/pyPL.gitcd pyPLpip install -r requirements.txtOnce the library is installed, you can import and use the classes to fetch FPL data.
You can run the example.py with your managerID to see your stats
FplCurrent retrieves general information about a manager’s FPL profile, such as their name, rank, points, and leagues they are part of. You can also access information about the manager’s favorite league and more.
from fpl import FplCurrent
manager = FplCurrent(managerID=1234567)
print(manager.name) # Manager's name
print(manager.summary_overall_points) # Total points in the game
print(manager.favorite_team) # Favorite teamClassicLeagues allows you to access detailed information about a specific classic league that the manager is part of. It includes the league’s ID, name, rank, and other league-related statistics.
from fpl import ClassicLeagues
manager = ClassicLeagues(managerID=1234567, n=0)
print(manager.C_name) # League name
print(manager.rank) # League rankActivePhases retrieves detailed information about a specific active phase of a classic league. This includes the phase rank, points, total, and percentile rank within the league.
from fpl import ActivePhases
manager = ActivePhases(managerID=1234567, n=0, phase_number=1)
print(manager.A_rank) # League rank in the current active phaseFplHistory allows you to access historical data for a specific gameweek, including points, rank, and other relevant statistics for that week.
from fpl import FplHistory
history = FplHistory(managerID=1234567, gameWeek=5)
print(history.points) # Points earned in gameweek 5
print(history.total_points) # Total points up to gameweek 5You can use the data from the FplHistory class to plot beautiful bar charts using libraries like matplotlib and plotly.
The code to the plot can be found here:
View the interactive plot PS: scroll down to see the chart
Contributions to pyPL are welcome! To contribute, fork the repository, create a branch for your feature or bug fix, and submit a pull request.
Props if you are blessed by the numpy gods and can optimise the code.
This project is licensed under the MIT License - see the LICENSE file for details.
