How-to build a match page with line-ups/formations

In this guide, we'll show you how to correctly build a match page that shows the line-up/formation of the teams. This is one of our most frequently asked questions. So, we decided to create a how-to guide that will show you exactly how you can load the line-ups/formations. This guide will walk you step by step, from requesting the line-up data to putting players in their correct line-up grid.

Step 1: Gather the tools

You are going to need the following tools:

  • SportMonks API token

  • Postman (optional)

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

Step 2: Get the fixture id for your match page

There are various ways to get fixture IDs such as:

For this guide, we’ll go with the following fixture id: 16924631 (Manchester United - Tottenham Hotspur). This fixture id is also the default fixture id in our Postman collection.

Because we want the line-up from both teams we add the includes lineup and bench. Furthermore, it's interesting to know which players cannot play due to an injury or suspension. You can add the sidelined include for this as well. If you want the full name of players, please refer to Step 5.

A snippet of the response:

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

Many of our users stop at this step, but some want to visually display the formation. In step 3 we’ll discuss how you can do that.

Step 3: Know how formation positions work

First, we want to know what formation, both teams used. Luckily, this information is included in the default response you get from our fixtures/livescores endpoints. For example:

        "formations": {
            "localteam_formation": "4-2-3-1",
            "visitorteam_formation": "4-3-3"

Before we fill in the formation, let us first explain formation positions.

In the example response from step 2, you could have noticed that the player's formation_position: 1. Our API slots formations from right to left, meaning that the visitorteam_formation will look like this for a classic 4-3-3 formation:

So, in this case, we have:

Formation Number

Outcome

1

Keeper

2

Right-back

3

Central defender

4

Central defender

5

Left-back

6

Right central midfielder

7

Central midfielder

8

Left central midfielder

9

Right-winger

10

Central forward

11

Left-winger

Step 4: Fill in the formation

Alright, back to filling in our formation. The visitor team used a 4-3-3 formation, while the visitor team used a 4-2-3-1 formation. So their respective formations will look like this:

1 (Goalkeeper)

Formation_position: 1 (Hugo Lloris)

4 (Defenders)

Formation_position: 2 (Serge Aurier)

Formation_position: 3 (Davinson Sánchez)

Formation_position: 4 (Eric Dier)

Formation_position: 5 (Sergio Reguilón)

3 (Midfielders)

Formation_position: 6 (Moussa Sissoko)

Formation_position: 7 (Pierre-Emile Højbjerg)

Formation_position: 8 (Tanguy Ndombélé)

3 (Attackers)

Formation_position: 9 (Érik Lamela)

Formation_position: 10 (Harry Kane)

Formation_position: 11 (Heung-Min Son)

You can follow the same principle for the away team.

And that is how you can fill in the correct formation with our API. For any further questions, you can simply contact us by email at support@sportmonks.com

Step 5: Advanced requests

The API will return the name of the player with the first name as initial and last name written fully e.g. H. Kane, instead of Harry Kane. In other cases, the player has a common name that isn’t the same as their actual full name. By using the nested include lineup.player, we can request all the player data we would need, including all their names.

https://soccer.sportmonks.com/api/v2.0/fixtures/16924631?api_token={API_TOKEN}&include=lineup.player

We can see the various names and more specific player info of player Harrry Kane with this request.

This marks the end of this how-to guide. We hope you have gotten a better understanding of how our API sorts the line-ups and how you can put it in the right formation. See you in the next how-to guide!

Last updated