Latest Posts

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

1 month ago 1 Comment

How to get data from the Fantasy Premier League API

Hi everyone! I’m moving a little bit away from what I’d normally post due to there being no Fantasy Football to be played. Sad times, I know. I’ve found there is a void in my life as of late, and I still find myself looking at the /r/fantasypl subreddit regularly even though I know we’re months away from the next season starting. I’m interested in statistics and coding, which may surprise some of you!

What I’ve found from using WordPress’s own platform is that the customization which you have while using their platform inhibited me from automating processes, from using custom databases and in turn having to use plugins which just didn’t do enough for the website, in my opinion.

So enough of me complaining about the WordPress Platform and back to using the FPL API. Some of you may not know that FPL provides an API which is available for free to developers to use (or people like me who feign knowledge of web development). Let me preface this by saying I am not an excellent developer or a massively knowledgeable coder, just someone who finds this interesting and wants to help others out.

First and foremost I’ll provide you with the URLs for their API:

There are a number of other sub URLs which can be used with appending the link onto the base URL below:

Base URL:

Relative links:

  • /bootstrap (more data if authenticated)
  • /bootstrap-static
  • /bootstrap-dynamic
  • /events
  • /elements
  • /element-types
  • /fixtures
  • /teams
  • /region
  • /transfers (requires auth)
  • /entry/{entryId}
  • /entries (doesn’t work in pre-season?)
  • /my-team/{teamId} (requires auth)
  • /leagues-entered/{teamId} (requires auth)
  • /leagues-classic/{leagueId} (must be a member)
  • /leagues-classic-standings/{leagueId}
  • /leagues-h2h/{leagueId} (must be a member)
  • /leagues-h2h-standings/{leagueId}

While I understand a lot of these URLs may be useless to you, we’ll be using two of them to pull data from players from the previous season. Originally we will be using the /bootstrap-static data. From clicking the link you can firstly see a section called “phases”, which from looking at the text following relates to sections of the season:

{“id”:1,”name”:”Overall”,”start_event”:1,”stop_event”:38} – Overall showing from GW1 to GW38.

{“id”:2,”name”:”August”,”start_event”:1,”stop_event”:3} – While ID 2, with the name of August showing from GW1 to GW3.

In the next bit of data, you can see that in “elements” it is showing you information about players. Taking some of the data from ID: 1, which oddly enough is David Ospina, you can see there is a vast amount of information on players from this alone:


Some of the most important from this section includes their:





….and so on. Okay, so, I know mostly php, html, and I know a bit about APIs. So I’m going to create this using my localhost, and using their API, while making a call via php. So that means nothing to you, right? Right. So lets just do this in the most easy way possible. STEPS!

Step 1: Download and Install XAMPP.

It is really straightforward, but if you’re struggling following the steps in this youtube video. If you aren’t running Windows 10, do a similar search on Youtube. XAMPP on Linux/Apple/Windows 7/Dos. This won’t work with a Chromebook, unfortunately.

Step 2: Download a text editor

Personally, I use Sublime 3, but a lot of people use notepad++, and some madmen even use Notepad. As we’re not that mad stick to Sublime or Notepad++.

Step 3: Get Coding!

So once your text editor and your xampp is setup we’ll begin coding. First and foremost, this is going to be completely functional, as much as I like frontend development, the purpose of this is to provide people with some knowledge on how to use the API and present it on a webpage.

First off lets begin the styling, some style is needed in any site to make it look half decent. Here is the code for you first half of your document:

<!DOCTYPE html>
#player_info {
 font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
 border-collapse: collapse;
 width: 100%;

#player_info td, #player_info th {
 border: 1px solid #ddd;
 padding: 8px;

#player_info tr:nth-child(even){background-color: #f2f2f2;}

#player_info tr:hover {background-color: #ddd;}

#player_info th {
 padding-top: 12px;
 padding-bottom: 12px;
 text-align: left;
 background-color: #242424;
 color: white;


This is the code which styles the webpage. This is just basic CSS.

In “#player_info” we choose the font.

With “#player_info td, #player_info th” we add a border and padding to cells.

At “#player_info tr:nth-child(even){background-color: #f2f2f2;}” we alternate the cell’s colours.

In “#player_info tr:hover” we make the cells change colour when you hover over them.

The code “#player_info th” is used for changing the colour of the header. Simple enough. This is just to make it look nice and pretty!

Next up we call the API by using PHP! Super interesting, I know! To do this we use the file_get_contents function, which gets all the contents from a website. In this case, it is the bootstrap-static page. We have given the call a php name of $json for further referencing it.


After we call the API, we then create another variable with the name of $data and use json_decode, which takes a JSON encoded string and converts it into a PHP variable. This enables us to finish the code. A guy in work suggested me to use guzzlephp, but I’m a noob and this works, so, meh. The code beneath is as follows:

$data = json_decode($json, true);

After this, we create a table because the styling we did above would go to waste if we didn’t, and I’m not here to waste your time.

So since this API has a LOT of different sections in it I’ve filtered some of the useless ones from it and only kept the 31 columns which I feel people will find useful. Yep, only 31. Okay so now back to the code, the table’s ID matches up to the CSS, and is labeled as player_info, while <tr> stands for table row,  <th> stands for table header and <td> just stands for a standard cell in a table.

<table id ="player_info">
 <th>Web Name</th>
 <th>Player ID</th>
 <th>Full Name</th>
 <th>Current Price</th>
 <th>Value Season</th>
 <th>Cost Change from Start</th>
 <th>Percentage selected by</th>
 <th>Transfers In</th>
 <th>Transfers Out</th>
 <th>Total Points</th> 
 <th>Points Per Game</th>
 <th>Goals Scored</th>
 <th>Clean Sheets</th>
 <th>Goals Conceded</th>
 <th>Own Goals</th>
 <th>Penalties Saved</th>
 <th>Penalties Missed</th>
 <th>Yellow Cards</th>
 <th>Red Cards</th>
 <th>Bonus Points</th>
 <th>Bonus Point System Score</th>
 <th>ICT Index</th>
 <th>EA Index</th>

As you can see from the above, there are a lot of headers, some of these are useful, some not so much, personally I’ll never choose a player based off of their EA index, but some freaks might. So from this, now we get into the nitty-gritty, the really incredibly difficult part of it.

foreach($data['elements'] as $key=>$item)

In the foreach statement uses the previously encoded JSON, which was created earlier in the $data variable. From just browsing to the URL: you can see that the JSON has multiple sections which can be pulled from the JSON, so we chose the section called elements to pull our data from, as phases wouldn’t be all that useful.


Each of these elements will then be entered as a $key of an array into the variable $item. This will enable us input all of the elements into a table thanks to the foreach loop, which won’t stop until there are no more elements to enter. One thing though, is that each item has to be related back to the API, and aligned to the header.

From the boostrap link, some of the names like now_cost and code, have to be input into the echo statement so it can call the API and input it into the table. Looking at the table above you can see that the first row is <th>ID</th>, while the first row in the PHP is  <td><?PHP echo $item[‘id’]; ?></td>. The row which is just ID, can be labeled anything as there is no call code to it, but the PHP echo $item call must call an element in the API. There are also matched up with the header row, so it is good to match them up to the table headers.

The code for that is:

 <td><?PHP echo $item['id']; ?></td>
 <td><?PHP echo $item['web_name']; ?></td>
 <td><?PHP echo $item['code']; ?></td>
 <td><?PHP echo $item['first_name']; ?> <?PHP echo $item['second_name']; ?></td>
 <td><?PHP echo $item['team_code']; ?></td>
 <td><?PHP echo $item['news']; ?></td>
 <td><?PHP echo $item['element_type']; ?></td>
 <td><?PHP echo $item['now_cost']; ?></td>
 <td><?PHP echo $item['value_season']; ?></td>
 <td><?PHP echo $item['cost_change_start']; ?></td>
 <td><?PHP echo $item['selected_by_percent']; ?></td>
 <td><?PHP echo $item['transfers_in']; ?></td>
 <td><?PHP echo $item['transfers_out']; ?></td>
 <td><?PHP echo $item['total_points']; ?></td> 
 <td><?PHP echo $item['points_per_game']; ?></td>
 <td><?PHP echo $item['minutes']; ?></td>
 <td><?PHP echo $item['goals_scored']; ?></td>
 <td><?PHP echo $item['assists']; ?></td>
 <td><?PHP echo $item['clean_sheets']; ?></td>
 <td><?PHP echo $item['goals_conceded']; ?></td>
 <td><?PHP echo $item['own_goals']; ?></td>
 <td><?PHP echo $item['penalties_saved']; ?></td>
 <td><?PHP echo $item['penalties_missed']; ?></td>
 <td><?PHP echo $item['yellow_cards']; ?></td>
 <td><?PHP echo $item['red_cards']; ?></td>
 <td><?PHP echo $item['saves']; ?></td>
 <td><?PHP echo $item['bonus']; ?></td>
 <td><?PHP echo $item['bps']; ?></td>
 <td><?PHP echo $item['influence']; ?></td>
 <td><?PHP echo $item['creativity']; ?></td>
 <td><?PHP echo $item['threat']; ?></td>
 <td><?PHP echo $item['ict_index']; ?></td>
 <td><?PHP echo $item['ea_index']; ?></td>

So there it is, our PHP page which pulls every player’s data from the API and presents it in a lovely (shitty) website. The site should look something like this:


If you wish to see the repo it is available on my GitHub here: and is the fplinfo.php file. I have a few others in there which I’ve struggled with over the year, mainly due to time, heartbreaks, hangovers, teaching Shano how to use the sum function in excel, and focusing on winning my money leagues.

I guess some of you wanted to download this data? God damn you. Fine, here, I’ll add a download button so a CSV file can be downloaded. Firstly, I added a button on top to download a CSV file, which onclick enables a javascript function.

<button onclick="doCSV()"">Export HTML Table To CSV File</button>

The function doCSV() is essentially a piece of javascript which replaces the HTML table’s tags with white space and commas, as well as creating line breaks. That took longer than expected. The /g is the replace function in javascript while having commas creates comma delimiters which are required in CSV files. The \r\n is a newline and a carriage return (i.e. move the cursor to the left), which starts a new line in the CSV file.

I placed this script at the bottom of the HTML.

<script>function doCSV() {
 var table = document.getElementById("player_info").innerHTML;
 var data = table.replace(/<thead>/g, '')
 .replace(/<\/thead>/g, '')
 .replace(/<tbody>/g, '')
 .replace(/<\/tbody>/g, '')
 .replace(/<tr>/g, '')
 .replace(/<\/tr>/g, '\r\n')
 .replace(/<th>/g, '')
 .replace(/<\/th>/g, ',')
 .replace(/<td>/g, '')
 .replace(/<\/td>/g, ',')
 .replace(/\t/g, '')
 .replace(/\n/g, '');
 var mylink = document.createElement('a'); = "fplinfo.csv";
 mylink.href = "data:application/csv," + escape(data);;

So yeah… I know, you don’t wanna do all of the above. Fine, you lazy fuck.

Download the file from here by clicking this.

So, if you think this has helped in any way, or you’ve appreciated any of the content we’ve done over the last year, buy us a beer, we’re Irish, we’d appreciate it. Cheers.

[simple-payment id=”6524″]

2 months ago No Comments

Goalscorer Probabilities and Expected Points – Gameweek 38

This has been a long year. I’m sad in some ways and ecstatic in some others. With many of our money leagues wrapping up I’m coming up trumps in pretty much all of the leagues I’m in except for the OddsOnFPL league, you bastards. Historically this game week has always thrown up a serious amount of goals, and defences become pretty much obsolete, with teams going gung-ho with little to play for. This season, not much is different. With Chelsea needing a massive goal swing for Champions League football, and Swansea needing as much to stay up, there is little to play for except for personal accolades.

As an aside, thank you all for your continued reading. Almost 50,000 unique readers have read the blog this year, it has been tough at times with work, and life sometimes taking priority, but I hope we have helped improve your ranking from sharing this information with you.


Harry Kane has looked unfit of late but has still scored 3 goals in his last 4 fixtures. He scored 3 goals in last year’s final fixture against Hull to guarantee the golden boot, could he do the same this season against a Leicester side who recently conceded 5 against Crystal Palace? Potentially. The bookies have Kane at a massive 70.29% chance of scoring at any time, with most bookies even having him as a 14% to score a hat trick. If anyone could, Kane could.

Pierre Emerick Aubameyang has proven already in half a season that he can do it in the Premier League. The former Dortmund attacker has adapted to the Premier League in no time scoring 9 goals in 11 starts. Phenomenal numbers. With Arsenal playing Huddersfield in Arsene’s last match can expect a strong performance from the Gunners. You should perhaps worry about their alarming away form in 2018 though. Arsenal have lost all 7 of their away Premier League fixtures, including losses to fellow promoted sides Brighton and Newcastle, could Huddersfield make it 3/3? The Gabonese attacker has a 55.70% chance of scoring in GW38.


Mohamed Salah has all but wrapped up the golden boot, and is looking to score more than Shearer and the rest who had 34, so he will be looking for goals, and comes up against a Brighton side who have likely been boozing since confirming their status as a Premier League side. The Egyptian is expected to score 8.02 points and is slightly higher to score at any time than Harry Kane with a probability of 71.68%.

Marko Arnautovic has played out of position pretty much all season long as an attacker, and it has proven to be one of David Moyes’ greatest decisions over the last few years. The Austrian attacker has proven to be a workhorse and a unique attacker, offering strong pressing, unlike Chicharito and Andy Carroll offer. With many Stoke fans previously laughing at West Ham paying £20 million for what they considered as a luxury player, who is having the last laugh now? Alongside Pascal Gross and Mohamed Salah, Arnie has been one of the signings of the season. Marko has a 41.53% chance of scoring against Everton in West Ham’s final game of the season.


Trent Alexander Arnold has been playing in midfield a little as of late. In Liverpool’s youth teams his has always played there, and technically he seems to be a better fit more centrally in the side. The young Liverpool player could be in with a shout of going to the world cup in place of Trippier or Nathaniel Clyne, and after some of his performances this season, it wouldn’t be unwarranted. Also, he wouldn’t have to come up against Marcus Rashford in international fixtures.

Patrick Van Aanholt has somewhat flown under the radar this season. The Dutch international has scored 4 goals this season, with 2 goals in his last 2 fixtures, including the goal which sent Stoke down to the Championship. The full back often is left with bucket loads of space due to the movement of Wilfried Zaha which leaves a so many defenders out of position and chasing the fast feet of the Ivorian international. England certainly missed a trick not playing Zaha in a competitive fixture.

[table id=282 /]

2 months ago No Comments

Clean Sheet Probabilities Gameweek 38 – #FPL

Well guys, it’s been a fun season. The last week is upon us until we go on a summer break. Hopefully the clean sheets have helped you make the tough calls and made you progress up the overall rankings.

With Liverpool one of the few teams with something to play it’s no surprise they’ve such a high expectancy to keep a clean sheet at 54.3% whilst Brighton have nothing to play.

Huddersfield have secured their premier league safety but face an Arsenal side who have failed to get any points away from home this season. Arsenal have a 36.52% chance of keeping a clean sheet but probably still best to avoid.

Unless Swansea manages to score a handful of goals as well as Man City absolutely smashing Southampton. Soton are all but safe. Pep will be chasing the 100 points mark so it’s tough to see Soton keeping a clean sheet here with just an 11.76% chance  whilst Manchester City have a 43.46%

[table id=281 /]

2 months ago No Comments

OddsOnFPL – Gameweek 37 Preview #FPL

Hi everyone, this is a weekly blog post where we document changes to our team based on bookie’s odds. We have been doing this since game week one and have shared with you our progress and regression thus far. This is not a wildcard XI or a team of the best possible players, this is an actual team which we have had since GW1 and have made changes to throughout the season. Currently, we’re 417,362nd in the world and aim to be top 1% by the end of the season with the help of the bookies. To view the team click the following link: OddsonFPLTeam

To join our league use the following code: Auto-Join Link

Last week we had a bit of an issue, I was in Canada, this meant not game week post, Pogba was benched, but we still moved up the rankings and have banked a transfer. Not forgetting we still have our triple captain. This can only mean one thing. We bring in Kane, and he gets the triple C.


Vice-captain is Sterling, who has been in phenomenal form as of late, and somehow we have 11 double game week players. I expect rotation, I expect 100+ points, and I hope only 50% of my predictions are correct. It is really the hope which kills you. As always, the decisions are made off of the bookie’s odds and a slight adjustment based on the likelihood of players to start. Sterling would be our captain if he was nailed on to play both fixtures, but knowing Pep he will rotate. Kane is this week’s triple captain.


3 months ago No Comments

Clean Sheet Probabilities Gameweek 37 – #FPL

Game week 37 is the final hurdle of the season in which many will be hoping to either hold onto their position or finally move ahead of league rivals. One thing you do have to consider is that the vast majority of players have given up at this stage, which automatically gives you an advantage. With Liverpool getting into the Champions League final it is unknown how strong a side they will play in their remaining fixtures. Manchester City will most likely rotate in defence. Manchester United may rotate with the cup final. Arsenal may field a stronger XI knowing they’re not in the Europa League final. Overall, its a headache disguised as an opportunity. 


Manchester City have what many would consider two easy fixtures in game week 37. In their first fixture of the game week they have a 69.78% chance of keeping a clean sheet against Huddersfield, and against Brighton, they have a 68.03% chance of keeping a clean sheet. With what may look like an easy decision to bring in a City defender, only one of their assets is nailed on, Ederson. Kompany is always an injury risk, Walker could be out for the season, Otamendi could be rotated and Delph is a midfielder in the game. Kompany and Walker were pictured in training, it could be false hope, stick or twist, it is your choice.

Spurs have a 48.83% probability of keeping a clean sheet against West Brom away, while against Newcastle at home they have a 54.86% chance of keeping a cleanie. Alderweireld will likely leave this during the summer, meaning Sanchez and Vertongen will likely start at centre-back. The two full backs will also likely rotate during the game week, Rose is looking for minutes before the world cup, and Aurier will likely get minutes at right back. The only suggestion I would advise for the game week is Vertongen. Lloris has been out of form as of late, making blunders, so a hit may not be advisable.


West Brom only have one fixture in gameweek 37 against Spurs. With Harry Kane looking for the golden boot, and West Brom all but mathematically relegated its unlikely they will keep a clean sheet. Get rid of the assets, I mean you should have months ago, but like, get rid of them now.

Despite the fact Huddersfield have two fixtures in game week 37 their defenders are incredibly unlikely to keep clean sheets, with only a 5.00% chance of keeping a clean sheet against Man City away, and in their second fixture, they’re only an 8.84% chance of keeping a clean sheet away to Chelsea. Two tough fixtures and a side fighting for their lives against much strong quality opposition can only mean one thing, no clean sheets.

[table id=280 /]

3 months ago No Comments

Goalscorer Probabilities and Expected Points – Gameweek 36

Sorry guys just a quick post this week as Paddy has abandoned me to go to Canada on a trip and Dan is busy with college.

No surprises who the most likely points scorer this week is. The King of Egypt Mo Salah. A fantastic season in which he’s set to break all sort of records sees him with a points expectancy of 7.71

  • Some players may be missing due to when the odds were done as they were done earlier in the week but the big hitters are there

[table id=279 /]

3 months ago No Comments

Clean Sheet Probabilities – Gameweek 36 #FPL

Spurs(59.61%) top the table this week which is a bit of a shock considering they have failed to keep a clean sheet in their last 5 games.

Liverpool have a 49.09% chance of keeping a clean sheet against a very poor Stoke side. Stoke are all but relegated and whilst their may be some rotation for Liverpool due to the Champions League game they should still have enough in the tank to stop Stoke from scoring.

With Joe Hart still in goal for West Ham, it’s no shock that they’ve only an 11.34% chance of keeping a clean sheet against the Champions of England.

Arsenal have failed to keep a clean sheet in their last 5 games. They travel to Old Trafford and have just a 15.05% of keeping a clean sheet.

[table id=278 /]

3 months ago No Comments

Clean Sheet Probabilities – Gameweek 35 #FPL

With only 6 fixtures in game week 35 we’re expected that a lot of squads will have glaring holes in their starting XI and that a lot of players will be using their free hit. With big hitters Liverpool, Arsenal and Manchester City all expected to beat their opposition comfortably all squads have little to no motivation to win their respective fixtures. Liverpool have a Champions League semi-final on the horizon, City have already won the league and Arsenal have packed it in and gone all in on winning the Europa League. All of the big sides are expected to massively rotate, and there could be some big upsets in GW35.

Of the remaining sides, West Brom are all but mathematically relegated. Stoke, on the other hand, have a small glimmer of hope of staying up, but against a resolute Burnley side they’re unlikely to score or get many chances to.

Manchester City are the heavy favourites with a 62.52% chance of keeping a cleany no surprise to see their opposition Swansea the lowest this week with just a 6.71% chance of keeping out City.

[table id=276 /]

3 months ago No Comments

Goalscorer Probabilities and Expected Points – Gameweek 35

With many big hitters from last week not playing in this, it is looking like it could be a low scoring week for many in 35, with many sides not being expected to be able to field an XI. If you’re one of the lucky ones with a free hit left, this could be the ideal week for your use of it.


Gabriel Jesus looks nailed on to lead the line for Man City between now and the end of the season following the news of Aguero’s injury during the week. If Man City are to break the points record then Jesus will have a big part to play in it, one would imagine.
As a differential then I would be leaning towards Jordan Ayew as a selection with GW37 in mind. Swansea will have a double gameweek in GW37 and he represents value in my opinion @ 5.3M


With the points record in mind, Manchester City should be all out for the wins between now and the end of the season despite having the league already wrapped up. Of the midfielders I would choose Sterling who will be keen to cement his place in the England side for the upcoming World Cup.
Iwobi for Arsenal would be my choice if you were looking for a differential to claw back some points. As mentioned previously, he will benefit from the double gameweek in GW37.


Slim pickings this week with only 6 games. Manchester City lead the clean sheet table and with the upcoming double gamweek for them in GW37, picking up a Otamendi would be a good move in my opinion. City are at home to Swansea on Sunday.
Mustafi for Arsenal also looks a solid choice going forward in my opinion. Arsenal also benefit from a double gameweek in GW37. Arsenal face West Ham on Sunday in the lunchtime kick off.
[table id=277 /]
3 months ago No Comments
Scroll to top