How-to build a team page

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 22/23 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:

These first endpoint returns the individual player statistics of all the players in a squad, the second endpoint returns statistics of the team.

We’ll show you how to work with the endpoints.

Step 4: the Request

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.

https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics

Step 5: Evaluate the response

{
  "data": {
    "id": 62,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8914,
    "gender": "male",
    "name": "Rangers",
    "short_code": "RAN",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/30/62.png",
    "founded": 1873,
    "type": "domestic",
    "placeholder": false,
    "last_played_at": "2023-02-26 15:00:00",
    "statistics": [
      {
        "id": 257394,
        "team_id": 62,
        "season_id": 19735,
        "has_values": true,
        "details": [
          {
            "id": 1932172,
            "team_statistic_id": 257394,
            "type_id": 214,
            "value": {
              "all": {
                "count": 20,
                "percentage": 76.92
              },
              "home": {
                "count": 11,
                "percentage": 55
              },
              "away": {
                "count": 9,
                "percentage": 45
              }
            },
            "type": {
              "id": 214,
              "name": "Team Wins",
              "code": "team-wins",
              "developer_name": "WIN",
              "model_type": "statistic",
              "stat_group": null
            }
          }
        ]
      }
    ]
  },
  // And more

Since the two requests return the same data, we’ll only show you the output of the GET Team Squad by ID and Season ID endpoint including statistics.

Let's look at Cody Gakpo’s World Cup stats. There’s a lot of information about his stats, such as minutes played, times he got substituted out, duels won, clean sheets, etc.

Now for the team by id endpoint with the statistics include, this request returns all the season with statistics. Please check out team statistics tutorial to learn how to filter on specific data.

Step 6: Extra’s

To add more to your team page you could add league standings and topscorer standings for the team you prefer.

You can retrieve seasonal standings; we simply have the endpoint: "GET Standings by Season ID."

https://api.sportmonks.com/v3/football/standings/seasons/{ID}?api_token=YOUR_TOKEN

There is a lot more information regarding their standings that you can opt to use for your application.

You can also add the top scorers' standings to your page. For that, we have created the topscorers endpoint.

https://api.sportmonks.com/v3/football/topscorers/seasons/{ID}?api_token=YOUR_TOKEN

By using these endpoints, you can add more depth to your team page.

Last updated