How-to build a match page with events and statistics

Welcome to our how-to guide about creating a match page that is filled with various events and statistics. This is a follow-up on the how-to build your livescore website guide. The livescore page only shows the live score of the match and sometimes the bigger events such as goals, substitutions, and cards. For basic knowledge about livescores, includes, and nested includes please see our tutorials.

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 which events and statistics you want to show

At SportMonks we offer the following events:

  • Goals

  • Red and yellow cards

  • Substitutions

  • VAR

  • Extra time

  • Score in between Half and Final time

  • Corners

For match statistics, think about anything that can happen during a match such as: The number of shots, passes, attacks, fouls, corners, offsides, yellow/red cards, saves, substitutions, goal attempts, penalties, injuries, and many more. Player statistics are all the relevant statistics regarding a player, such as the number of goals scored, how many fouls he made, and the number of cards received, etc.

Step 3: Choose the correct endpoint/include

Events

The standard events include consists of goals, substitutions, and cards. There is also the include called corners and many more. For a full list of the possible includes see our API reference guide.

Statistics

Player and match statistics do not have endpoints, but instead can be evoked with includes.

  • Match statistics use the include stats.

  • Player statistics use the includes lineup and bench.

Lineup only gives us the 11 starting players, while we want everyone from the bench as well.

Since this is about a single match page with various events and stats, we will need the specific fixture ID. Henceforth, we’ll work with the fixtures by id endpoint.

It’s also possible to include both stats, lineup and bench includes in the same request, but expect a lengthy response in that case.

Head-2-head

You can compare two teams' past results against each other. This is often used to see how one team performs against another. This endpoint is simply called head2head.

Step 4: Example basic requests

In this how-to guide, we’ll show you how to request events data, player and match statistics, and head2head data:

https://soccer.sportmonks.com/api/v2.0/fixtures/{ID}?api_token={API_TOKEN}&include=stats,lineup,bench,events

It’s also possible to use the stats and lineup includes in the head2head endpoint, in case you want to show even more in-depth data about the history of these matches.

Step 5: Evaluate the response

"data": [
                {
                    "team_id": 53,
                    "fixture_id": 16475287,
                    "player_id": 172923,
                    "player_name": "S. Bain",
                    "number": 29,
                    "position": "G",
                    "additional_position": null,
                    "formation_position": 1,
                    "posx": null,
                    "posy": null,
                    "captain": false,
                    "type": "lineup",
                    "stats": {
                        "shots": {
                            "shots_total": 0,
                            "shots_on_goal": 0
                        },
                        "goals": {
                            "scored": 0,
                            "assists": 0,
                            "conceded": 1,
                            "owngoals": 0
                        },
                        "fouls": {
                            "drawn": 0,
                            "committed": 0
                        },
                        "cards": {
                            "yellowcards": 0,
                            "redcards": 0,
                            "yellowredcards": 0
                        },
                        "passing": {
                            "total_crosses": 0,
                            "crosses_accuracy": 0,
                            "passes": 23,
                            "accurate_passes": 20,
                            "passes_accuracy": 91,
                            "key_passes": 0
                        },
                        "dribbles": {
                            "attempts": 0,
                            "success": 0,
                            "dribbled_past": 0
                        },
                        "duels": {
                            "total": 1,
                            "won": 1
                        },
                        "other": {
                            "aerials_won": null,
                            "punches": null,
                            "offsides": 0,
                            "saves": 1,
                            "inside_box_saves": 0,
                            "pen_scored": 0,
                            "pen_missed": 0,
                            "pen_saved": 0,
                            "pen_committed": 0,
                            "pen_won": 0,
                            "hit_woodwork": 0,
                            "tackles": 0,
                            "blocks": 0,
                            "interceptions": 0,
                            "clearances": 0,
                            "dispossesed": 0,
                            "minutes_played": 90
                        },
                        "rating": "6.42"
                    }

Player statistics

Here, we can see the detailed player statistics of the player named S. Bain. Apart from standard player information such as which team he belongs to, what his player id or position is. We can see the total number of shots, goals, fouls, cards, passing, dribbles and duels. There’s also an ‘other’ tab with even more information, but we won’t go into detail for that one.

Team statistics

As its name suggests, we can see the team statistics of the home team. We can see the number of shots, passes, attacks, and a plethora of other data of the entire team.

Events

Events show goals, cards, and substitutions and at which exact minute this happened. So, we can see that in the 14th-minute player S. Rosted scored the 0-1 and got an assist from J. Lindstrom.

Player J. Lauridsen got substituted for M. Kallesoe in the 25th minute. And finally, player M. Schwabe got a yellow card in the 91st minute.

Head2head

Now for the head2head, you’ll probably get a huge response because head2head is every single encounter the two teams have had. The most recent ones will be on top of the list. General information about each match will be given, such as its fixture id, season id, winner of the match, the final score, date of when the game was played, how many minutes the match was, and much more.

In case, you want to see the lineups of players who played at the time, you can simply add the include lineup,bench.

For an overview of field descriptions, you can refer to our statuses and definitions.

Last updated