Updates

August 2019

  • For the new 19/20 season, FPL have changed their api. The core code is probably the same, just the links have changed. I will update the app accordingly in time before the end of the season.

May 2019

  • Updated to version 2.0

  • Support for 2019 - 2020 Season

  • Added Percentil Gameweek Rank and Percentile Overall Rank Columns. 

FPL Data Fetcher 

With over 5 million players, Fantasy Premier League is the biggest Fantasy Football game in the world. It’s FREE to play and you can win great prizes!  Start playing now at  https://fantasy.premierleague.com/

I follow the English premier league religiously and playing fantasy football is one of my favorite hobbies. Every season millions of players participate in this exciting contest and there are multiple prizes and bragging points to gain throughout the season.

Archiving your season's data is a popular thing among many fpl players. With the amount of detail involved in each team, doing this manually is a very tedious process. So I decided to write a script in Python 3, which does this automatically.

This is my first 'serious' script in Python. I started learning it recently and decided this would be a great opportunity to test my skills in the software. I'm aware there is a possibility something like this already exists considering the number of 3rd party statistics sites available. But I wanted to make my own script, and decided to compile it into a windows application to make it easy for those who don't have access to Python. 

That said, you can also use the raw code and play with it. The project 'design' is up on my github. You can view it here.

The Excel sheet is color coded. The default colors are good, but you can make it even prettier by customizing your own like I did. 

How to use the application

Prerequisites

  • Make sure you are using this application after the season ends. There is some data that can only be fetched at the end of the season. You can try it closer to the end, but I recommend just waiting. You have from the end of May till mid-July (If I'm not wrong)

  • A Windows based system. This WILL NOT work on Mac OS. Apologies. 

  • Microsoft Excel 2010 or newer. No support for Google sheets yet. 

  • A zip file extractor. Windows has a built in extractor but I recommend something like 7-zip.

  • Your fpl ID. You can find this on the web address when you go to your 'Points' page. 

  • An internet connection. 

Using the application

  • Download the zip folder 'FPLDataFetcherx32' from the github page here. Make sure to get the file from v2.0 'assets' section.

  • Extract the folder using a zip file extractor.

  • Scroll down and launch the file FPLDataFetcher.exe

  • You should be greeted with a window with the premier league logo and a text box where you can enter your fpl ID.

  • Enter your fpl ID, and click Submit.

  • This will take some time depending on your internet connection, the application won't respond during this time.

  • After it is done, it will display the location of your file. 

  • Done!

 

Under the hood

To put it in very simple terms, the application takes data from the fpl website using json and imports it to an excel spreadsheet. 

View the project on Github​.

Modules Used.

  • tkinter - for GUI

  • openpyxl - to write the imported data to excel workbook

  • requests - to fetch json data from FPL website

  • os - to show the path of the created excel file

  • I've also used urlopen and base64 to read the FPL logo off of an imgur link to place it in the GUI

Here is the list of data imported from the website

  • Gameweek Score

  • Gameweek Average Score

  • Points Benched

  • Transfers Made for GW

  • Transfer Cost

  • Gameweek Rank

  • Overall Points

  • Overall Rank

  • Percentile GW Rank (v2.0)

  • Percentile Overall Rank (v2.0)

  • Position in overall leaderboard

  • Team Value

  • Weekly Squad with captain and vice captain selections highlighted

  • Individual player scores for each GW

  • Chips used and when

  • Complete transfer history with player values

  • FPL Cup History

  • Classic League Ranks

  • H2H Ranks

  • Weekly Dream Team with Scores

  • Final Dream Team

JSON links used