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 here.

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.

Squad by team and season id
Teams by id
Squad by team and season id
https://soccer.sportmonks.com/api/v2.0/squad/season/{ID}/team/{ID}?api_token={API_TOKEN}&include=player
Teams by id
https://soccer.sportmonks.com/api/v2.0/teams/{ID}/?api_token={API_TOKEN}&include=squad.player&season_id={ID}

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:

https://soccer.sportmonks.com/api/v2.0/teams/{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.

Request
Response
Request
https://soccer.sportmonks.com/api/v2.0/squad/season/{ID}/team/{ID}?api_token={API_TOKEN}&include=player
Response
{
"player_id": 171725,
"position_id": 3,
"number": 8,
"captain": 1,
"injured": false,
"minutes": 896,
"appearences": 12,
"lineups": 10,
"substitute_in": 2,
"substitute_out": 3,
"substitutes_on_bench": 2,
"goals": null,
"owngoals": null,
"assists": null,
"saves": null,
"inside_box_saves": null,
"dispossesed": 37,
"interceptions": 14,
"yellowcards": 5,
"yellowred": null,
"redcards": null,
"tackles": 18,
"blocks": null,
"hit_post": null,
"cleansheets": 5,
"rating": "6.93",
"fouls": {
"committed": 17,
"drawn": 24
},
"crosses": {
"total": 1,
"accurate": 0
},
"dribbles": {
"attempts": 7,
"success": 5,
"dribbled_past": 9
},
"duels": {
"total": 107,
"won": 64
},
"passes": {
"total": 655,
"accuracy": 49,
"key_passes": 10
},
"penalties": {
"won": null,
"scores": null,
"missed": null,
"committed": null,
"saves": null
},
"shots": {
"shots_total": 7,
"shots_on_target": 1,
"shots_off_target": null
},
"player": {
"data": {
"player_id": 171725,
"team_id": 53,
"country_id": 1161,
"position_id": 3,
"common_name": "S. Brown",
"display_name": "Scott Brown",
"fullname": "Scott Brown",
"firstname": "Scott",
"lastname": "Brown",
"nationality": "Scotland",
"birthdate": "25/06/1985",
"birthcountry": "Scotland",
"birthplace": "Dunfermline",
"height": "165 cm",
"weight": "64 kg",
"image_path": "https://cdn.sportmonks.com/images/soccer/players/13/171725.png"
}
}

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:

Request
Response
Request
https://soccer.sportmonks.com/api/v2.0/teams/{ID}/?api_token={API_TOKEN}&include=squad.player&season_id={ID}
Response
{
"team_id": 53,
"season_id": 17141,
"stage_id": 77447501,
"win": {
"total": 9,
"home": 4,
"away": 5
},
"draw": {
"total": 2,
"home": 0,
"away": 2
},
"lost": {
"total": 1,
"home": 1,
"away": 0
},
"goals_for": {
"total": 32,
"home": 14,
"away": 18
},
"goals_against": {
"total": 11,
"home": 5,
"away": 6
},
"clean_sheet": {
"total": 5,
"home": 2,
"away": 3
},
"failed_to_score": {
"total": 1,
"home": 1,
"away": 0
},
"scoring_minutes": [
{
"period": [
{
"minute": "0-15",
"count": 4,
"percentage": 12.5
},
{
"minute": "15-30",
"count": 6,
"percentage": 18.8
},
{
"minute": "30-45",
"count": 4,
"percentage": 12.5
},
{
"minute": "45-60",
"count": 5,
"percentage": 15.6
},
{
"minute": "60-75",
"count": 3,
"percentage": 9.4
},
{
"minute": "75-90",
"count": 10,
"percentage": 31.3
}
]
}
],
"goals_conceded_minutes": [
{
"period": [
{
"minute": "0-15",
"count": 2,
"percentage": 18.2
},
{
"minute": "15-30",
"count": 2,
"percentage": 18.2
},
{
"minute": "30-45",
"count": 2,
"percentage": 18.2
},
{
"minute": "45-60",
"count": 1,
"percentage": 9.1
},
{
"minute": "60-75",
"count": 2,
"percentage": 18.2
},
{
"minute": "75-90",
"count": 2,
"percentage": 18.2
}
]
}
],
"avg_goals_per_game_scored": {
"total": 2.67,
"home": 2.8,
"away": 2.57
},
"avg_goals_per_game_conceded": {
"total": 0.92,
"home": 1,
"away": 0.86
},
"avg_first_goal_scored": {
"total": "32m",
"home": "22m",
"away": "38m"
},
"avg_first_goal_conceded": {
"total": "28m",
"home": "36m",
"away": "13m"
},
"attacks": 1534,
"dangerous_attacks": 766,
"avg_ball_possession_percentage": "66.58",
"fouls": 84,
"avg_fouls_per_game": "7.00",
"offsides": 13,
"redcards": 0,
"yellowcards": 13,
"shots_blocked": 32,
"shots_off_target": 129,
"avg_shots_off_target_per_game": "10.75",
"shots_on_target": 79,
"avg_shots_on_target_per_game": "6.58",
"avg_corners": "5.92",
"total_corners": 71,
"btts": 50,
"goal_line": {
"over": {
"0_5": {
"home": 100,
"away": 100
},
"1_5": {
"home": 100,
"away": 85.71
},
"2_5": {
"home": 80,
"away": 57.14
},
"3_5": {
"home": 40,
"away": 42.86
},
"4_5": {
"home": 40,
"away": 42.86
},
"5_5": {
"home": 20,
"away": 14.29
}
},
"under": {
"0_5": {
"home": 0,
"away": 0
},
"1_5": {
"home": 0,
"away": 14.29
},
"2_5": {
"home": 20,
"away": 42.86
},
"3_5": {
"home": 60,
"away": 57.14
},
"4_5": {
"home": 60,
"away": 57.14
},
"5_5": {
"home": 80,
"away": 85.71
}
}
},
"avg_player_rating": 6.94,
"avg_player_rating_per_match": 7,
"tackles": 359
},

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.