A popular application for our football data is football fantasy games. Fantasy games are games where participants assemble a cast of real-life characters for a virtual team. This virtual team mimics their real-life counterparts. Everything is statistic-based.
If, for instance, you have Cristiano Ronaldo in your fantasy team and he manages to score a hattrick during an actual match, then this increase in performance will be reflected on your virtual Cristiano Ronaldo.
The player of a fantasy game is able to draft, trade, and drop players from their teams. The end goal is to assemble a team that is able to win the championship, which is very akin to real sports.
In this how-to guide, we’ll show you the most important features of a good sports fantasy game and why our SportMonks APIs are perfectly suited for the job of building a fantasy game.
So, you’ve decided to create your own fantasy game. One of the first things you will need to do for yourself is to determine the leagues you want to include in your fantasy game.
Many existing fantasy games base their game on one big league. However, you can also choose to combine multiple leagues.
With more than 1200+ leagues to choose from, we definitely have one or multiple leagues you can base your fantasy game on. You can request all the leagues we have via our all leagues endpoint:
However, please keep in mind that the coverage is not the same for every league.
For a fantasy game, you want to gather as much data as possible. Therefore, we suggest checking out our coverage page and only select leagues with minimum basic player statistics, but detailed statistics are recommended. Of course, for all major leagues, detailed statistics are available.
The Season statistics endpoint gives you great insight into how ‘attractive’ the league is. It gives you information about the average goals scored per match, average cards per match, and the average player rating. Especially the average player rating is interesting because you can show your app users this rating. More about this later.
Let’s say you’ve chosen to make a fantasy game for the German Bundesliga (league id: 82). You now need to gather the right information. Since you want to build a live fantasy game, the active season id might be a good starting point.
As you know, you can request the active season id by enriching your request with
Now that you have the season's current id, you can request the corresponding information like season statistics, participating teams and, of course, the players.
You can request the season statistics by using the season by id endpoint with
However, to save yourself from making an extra request, you can also use the nested include
season.stats on our league by id endpoint:
Now that we have all the season statistics, we need to gather all the teams and the squads participating in this season.
The squads are one of the most important pieces of data you need to gather if you want to build a fantasy game. Eventually, your application users need to select their own team with the players participating in this season. The fastest and most efficient way to retrieve all the teams of one season is to use our teams by season id endpoint:
This request will give you all the teams participating in this season with their basic team information.
Now, you can also include all the team squads in this season:
It might be good to use a nested include as well to get extra player information in the response:
Now you can show your users all the players that are participating in the season. With this information, you can give the users an overview of the active players, after which they can select their own team.
Now the essential part of a fantasy game: selecting the players. The user can select their own team (i.e. 11 players + 5 on the bench) based on the rules you decide for yourself. Some of the most used key principles:
Naturally, you need to limit the number of players from the same club. You want to avoid that one user chooses the whole squad of Bayern Munich, as they will probably score a lot of points with that team. The game needs to be challenging and fun at the same time. Therefore most existing fantasy games have a rule of max 2 players from the same team. Of course, you can determine your own guidelines.
Each player has his own value (€). You need to determine this value yourself, which you can do by using our data. For example, you can look at the player transfer history, but the better option is to look at the player rating of the previous season. E.g. the player rating and stats of Robert Lewandowski (id: 31000) for the 2019/2020 Bundesliga season (id: 16264):
Now you know that he had a rating of 7.67 in the previous season. That’s pretty high. Therefore, he is more valuable (€) than, for instance, a player with an average rating of 5.65. Get the idea?
As discussed, some players represent a different value than other players. To avoid users choosing the best players possible, you will need to set a budget. Within this budget, they can select their team.
Players will be restricted by their budget and will have to spend it wisely on a decent team.
Your application users have assembled their dream team. Now it’s time for them to select their starting 11. They will need to know which teams are playing against each other to make their selection. You can retrieve the upcoming season matches for this.
Season by id endpoint with the
Now, they can determine which players will earn the most points for the upcoming playing round. But how can you assign fantasy points to the players?
Just like with the player selection, you can decide for yourself what kind of fantasy point system you’re going to apply. Some of the most used key principles are:
Points based on starting eleven
The first and most used method is to assign points to the players that are in the starting eleven. You can see this as a sort of starting bonus. Players who start the game will get an 'X' amount of basic points. This also encourages your users to keep a good eye on the injured/suspended players and the predicted line-up.
You can request the starting eleven with the
lineupinclude on our livescores and fixtures endpoints. You need to add the
benchinclude as well if you want the players that are on the bench.
Points based on minutes played
Of course, every player that starts the game deserves some starting points. But what if a player is injured or gets a red card in the first few minutes? Logically speaking, players who do not play the full match receive fewer points. You can see how many minutes a player has played in the stats of each player. You can use the
bench include for this.
Win points based on stats
Also available in the
bench include are the statistics. Players who have scored or assisted a goal earn more fantasy points than players who didn't. It’s good to take the position of a player into consideration as well: a defender who scores or assists with a goal deserves more points than a striker, don’t you think?
Lose points based on stats
A player not only earns points but is also able to lose them. What if they conceded many goals, received a yellow or even a red card? These are all things you need to take into consideration and can be found in the
We hope this has given you some inspiration for your own fantasy game. Please do not hesitate to contact our support team with any questions you might have.