How-to build a team page with season stats and squads

Welcome to our guide about building a team page that shows the squad of a team for a specific season, as well as the seasonal statistics of the team. A squad is the entire group of players related to a team in a particular Season.

We’ll show you three different endpoints that you can work with to get the seasonal statistics and squad data. Afterward, we’ll show you a basic implementation process in order to build the team page. We'll show you example requests of the Scottish Premiership team Celtic of the 20/21 season. This league is included in our free plan, so feel free to make the requests yourself.

Step 1: Gather the tools

You are going to need the following tools:

  • Sportmonks API token

  • Code editor (Visual studio used in examples)

  • Postman (optional)

You can find a link to another article where we discuss the tools in-depth on our Developer Tools Guide.

Step 2: Decide what data you want to show

Squad statistics

To get all players of a squad and squad stats, you can opt to only show the current season, but if you value historic data, then you might as well show past iterations of the squad. It’s common to show all the members of the squad on one page for a nice overview of all their statistics, such as:

  • Player names

  • Playtime

  • Number of appearances in matches

  • Number of times substituted in or out

  • Number of goals scored, assists given

  • Number of cards received

And many more!

Team seasonal statistics

You can have statistics about almost anything in sports. So, it’s up to you to decide what statistics you want to show to your users. At SportMonks we offer you highly detailed season statistics per team such as:

  • Win-loss record

  • Number of attacks, fouls, cards, saves

  • Clean sheets

  • Number of goals scored between minute 0 and 15, or between minutes 75 and 90

  • Ranking and how many points they have

  • Average time for first goal scored/conceded

  • Average number of goals per match/win

And much more!

Step 3: Choose the correct endpoints

As mentioned before, we will discuss three different endpoints:

The first two request the individual player statistics of all the players in a squad, but in different ways, while the last one requests the statistics of the entire squad for either all the seasons for historical data or just for one specific season.

We’ll show you how to work with all three endpoints.

Step 4: Example requests

Individual player statistics of a squad

The squad by team and season id endpoint requires you to simply fill in the ids of the season and team you want. While the team by id endpoint has you fill in the team id and filter on season id.{ID}/team/{ID}?api_token={API_TOKEN}&include=player

Note that for the get squad by season and team id includes, we added the includeplayerfor more detailed player information. For team by id, we enriched the request with nested includes and filtered on season id.

Team season statistics

Probably the simplest of them all. This request also uses the team by id endpoint but the difference is that we use the include stats:{ID}/?api_token={API_TOKEN}&include=stats&seasons={ID}

This request also filters on the season id that you’re interested in. This is optional as some web applications also like to show historical team statistics. In this how-to guide, we’ll work with the current season id.

Step 5: Evaluate the response

Individual player statistics of a squad

Since the two requests return the same data, we’ll only show you the output of the squad by team and season id endpoint.{ID}/team/{ID}?api_token={API_TOKEN}&include=player

Let's look at Celtic's captain Scott Brown. There’s a lot of information about his stats, such as minutes played, times he got substituted out, duels won, clean sheets, etc.

Lastly, there’s detailed information about the player, such as his name, height, weight, date of birth, etc.

Team season statistics

Now for the team by id endpoint with the stats include:{ID}/?api_token={API_TOKEN}&include=squad.player&season_id={ID}

Without a filter this request will give you all seasons stats that Celtic has played in, starting chronologically from the first to the most current season.

For convenience, we once again show you the statistics of their current season. The request contains lots of detailed information for you to use as you please.

Last updated