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

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:

Request events, player and match statistics
Request head2head
Request events, player and match statistics
https://soccer.sportmonks.com/api/v2.0/fixtures/{ID}?api_token={API_TOKEN}&include=stats,lineup,bench,events
Request head2head
https://soccer.sportmonks.com/api/v2.0/head2head/{TEAM1_ID}/{TEAM2_ID}/?api_token={API_TOKEN}

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

Response player statistics
Response team statistics
Response Events
Response Head2Head
Response player statistics
"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"
}
Response team statistics
"stats": {
"data": [
{
"team_id": 53,
"fixture_id": 16475287,
"shots": {
"total": 28,
"ongoal": 15,
"blocked": 6,
"offgoal": 13,
"insidebox": 18,
"outsidebox": 7
},
"passes": {
"total": 670,
"accurate": 587,
"percentage": 87.61
},
"attacks": {
"attacks": 115,
"dangerous_attacks": 55
},
"fouls": 9,
"corners": 11,
"offsides": 0,
"possessiontime": 80,
"yellowcards": 1,
"redcards": 0,
"yellowredcards": 0,
"saves": 1,
"substitutions": 4,
"goal_kick": null,
"goal_attempts": 19,
"free_kick": null,
"throw_in": null,
"ball_safe": 91,
"goals": 5,
"penalties": 0,
"injuries": 0
},
{
"team_id": 338,
"fixture_id": 16475287,
"shots": {
"total": 6,
"ongoal": 2,
"blocked": 1,
"offgoal": 4,
"insidebox": 4,
"outsidebox": 3
},
"passes": {
"total": 157,
"accurate": 85,
"percentage": 54.14
},
"attacks": {
"attacks": 70,
"dangerous_attacks": 41
},
"fouls": 9,
"corners": 8,
"offsides": 2,
"possessiontime": 20,
"yellowcards": 3,
"redcards": 0,
"yellowredcards": 0,
"saves": 9,
"substitutions": 3,
"goal_kick": null,
"goal_attempts": 7,
"free_kick": null,
"throw_in": null,
"ball_safe": 67,
"goals": 1,
"penalties": 0,
"injuries": 1
}
Response Events
"events": {
"data": [
{
"id": 16475287001,
"team_id": "338",
"type": "yellowcard",
"var_result": null,
"fixture_id": 16475287,
"player_id": 174161,
"player_name": "S. Martin",
"related_player_id": null,
"related_player_name": null,
"minute": 17,
"extra_minute": null,
"reason": null,
"injuried": null,
"result": null
},
{
"id": 16475287002,
"team_id": "53",
"type": "goal",
"var_result": null,
"fixture_id": 16475287,
"player_id": 96792,
"player_name": "O. Édouard",
"related_player_id": 173080,
"related_player_name": "G. Taylor",
"minute": 20,
"extra_minute": null,
"reason": null,
"injuried": null,
"result": "1-0"
},
{
"id": 16475287003,
"team_id": "53",
"type": "goal",
"var_result": null,
"fixture_id": 16475287,
"player_id": 8403182,
"player_name": "J. Frimpong",
"related_player_id": 173080,
"related_player_name": "G. Taylor",
"minute": 31,
"extra_minute": null,
"reason": null,
"injuried": null,
"result": "2-0"
},
{
"id": 16475287004,
"team_id": "338",
"type": "own-goal",
"var_result": null,
"fixture_id": 16475287,
"player_id": 32761,
"player_name": "C. Jullien",
"related_player_id": null,
"related_player_name": null,
"minute": 34,
"extra_minute": null,
"reason": null,
"injuried": null,
"result": "2-1"
},
{
"id": 16475287005,
"team_id": "338",
"type": "yellowcard",
"var_result": null,
"fixture_id": 16475287,
"player_id": 173774,
"player_name": "R. Callachan",
"related_player_id": null,
"related_player_name": null,
"minute": 36,
"extra_minute": null,
"reason": null,
"injuried": null,
"result": null
},
{
"id": 16475287006,
"team_id": "338",
"type": "substitution",
"var_result": null,
"fixture_id": 16475287,
"player_id": 111635,
"player_name": "M. Ogkmpoe",
"related_player_id": 173093,
"related_player_name": "R. Hughes",
"minute": 42,
"extra_minute": null,
"reason": null,
"injuried": null,
"result": null
Response Head2Head
"data": [
{
"id": 16475287,
"league_id": 501,
"season_id": 17141,
"stage_id": 77447501,
"round_id": 194968,
"group_id": null,
"aggregate_id": null,
"venue_id": 8909,
"referee_id": 14859,
"localteam_id": 53,
"visitorteam_id": 338,
"winner_team_id": 53,
"weather_report": {
"code": "clouds",
"type": "few clouds",
"icon": "https://cdn.sportmonks.com/images/weather/02d.png",
"temperature": {
"temp": 59.94,
"unit": "fahrenheit"
},
"temperature_celcius": {
"temp": 15.5,
"unit": "celcius"
},
"clouds": "20%",
"humidity": "67%",
"pressure": 1014,
"wind": {
"speed": "10.29 m/s",
"degree": 300
},
"coordinates": {
"lat": 55.87,
"lon": -4.26
},
"updated_at": "2020-08-02T17:15:04.814798Z"
},
"commentaries": false,
"attendance": null,
"pitch": null,
"details": null,
"neutral_venue": false,
"winning_odds_calculated": true,
"formations": {
"localteam_formation": "4-2-3-1",
"visitorteam_formation": "4-4-2"
},
"scores": {
"localteam_score": 5,
"visitorteam_score": 1,
"localteam_pen_score": null,
"visitorteam_pen_score": null,
"ht_score": "2-1",
"ft_score": "5-1",
"et_score": null,
"ps_score": null
},
"time": {
"status": "FT",
"starting_at": {
"date_time": "2020-08-02 15:30:00",
"date": "2020-08-02",
"time": "15:30:00",
"timestamp": 1596382200,
"timezone": "UTC"
},
"minute": 90,
"second": null,
"added_time": null,
"extra_minute": null,
"injury_time": null
},
"coaches": {
"localteam_coach_id": 1467946,
"visitorteam_coach_id": 30082158
},
"standings": {
"localteam_position": 1,
"visitorteam_position": 12
},
"assistants": {
"first_assistant_id": 12118,
"second_assistant_id": 17249,
"fourth_official_id": 15815
},
"leg": "1/1",
"colors": {
"localteam": {
"color": "#007848",
"kit_colors": "#F0F0F0,#139343,#5B0623,#0A0A0A,#5C8FAE,#FFDF1B,#F0F0F0"
},
"visitorteam": {
"color": "#0046A8",
"kit_colors": "#0046A8,#0046A8,#0046A8,#0046A8,#C40010,#0046A8,#0046A8"
}
},
"deleted": false
},
{
"id": 11879682,
"league_id": 501,
"season_id": 16222,
"stage_id": 77444704,
"round_id": 173664,
"group_id": null,
"aggregate_id": null,
"venue_id": 288196,
"referee_id": 14468,
"localteam_id": 338,
"visitorteam_id": 53,
"winner_team_id": 53,
"weather_report": {
"code": "clear",
"type": "clear sky",
"icon": "https://cdn.sportmonks.com/images/weather/01d.png",
"temperature": {
"temp": 38.34,
"unit": "fahrenheit"
},
"temperature_celcius": {
"temp": 3.5,
"unit": "celcius"
},
"clouds": "1%",
"humidity": "80%",
"pressure": 1005,
"wind": {
"speed": "8.05 m/s",
"degree": 200
},
"coordinates": {
"lat": 39.18,
"lon": -84.53
},
"updated_at": "2020-02-02T14:15:03.048051Z"
},
"commentaries": true,
"attendance": 4708,
"pitch": null,
"details": null,
"neutral_venue": false,
"winning_odds_calculated": true,
"formations": {
"localteam_formation": "4-1-4-1",
"visitorteam_formation": "3-5-2"
},
"scores": {
"localteam_score": 1,
"visitorteam_score": 4,
"localteam_pen_score": null,
"visitorteam_pen_score": null,
"ht_score": "1-1",
"ft_score": "1-4",
"et_score": null,
"ps_score": null
},
"time": {
"status": "FT",
"starting_at": {
"date_time": "2020-02-02 12:30:00",
"date": "2020-02-02",
"time": "12:30:00",
"timestamp": 1580646600,
"timezone": "UTC"
},
"minute": 90,
"second": null,
"added_time": null,
"extra_minute": null,
"injury_time": null
},
"coaches": {
"localteam_coach_id": 30082158,
"visitorteam_coach_id": 1467946
},
"standings": {
"localteam_position": 12,
"visitorteam_position": 1
},
"assistants": {
"first_assistant_id": 12122,
"second_assistant_id": 21451,
"fourth_official_id": 17250
},
"leg": "1/1",
"colors": {
"localteam": {
"color": "#D6003D",
"kit_colors": "#F0F0F0,#D6003D,#5B0623,#0A0A0A,#5C8FAE,#FFDF1B,#F0F0F0"
},
"visitorteam": {
"color": "#007848",
"kit_colors": "#F0F0F0,#139343,#5B0623,#0A0A0A,#5C8FAE,#FFDF1B,#F0F0F0"
}
},
"deleted": false
},

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 is, and position. 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 what 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.