How-to build a schedule page

Welcome to the how-to build a season fixture schedule guide. This is a follow-up on the rounds, groups and stages tutorial. Rounds, groups and stages are, in fact, the building blocks of a season schedule. Now, in this how-to guide, we will use those building blocks to create a season fixture schedule. This schedule will show all the fixtures yet to come. We’ll show you how to create a season fixture schedule for the English Premier League (league id: 8) and one for the Champions League (league id: 2).

Step 1: Assemble the tools

You’re going to need the following tools:

  • Sportmonks API token

  • Code editor (Visual studio used in examples)

  • Postman (optional)

Step 2: Request the rounds of the English Premier League

We chose the English Premier League because it’s a domestic league without any different stages or groups, but it does have multiple rounds across their season. That’s why we’re going to request the rounds of the English Premier League season 20/21 (season id: 17420). We’ll use the following URL:

https://soccer.sportmonks.com/api/v2.0/seasons/17420?api_token={API_TOKEN}&include=rounds

Now that we have all the English Premier League rounds, we want to check which fixture ids are associated with each round. Here are several examples of correct requests:

https://soccer.sportmonks.com/api/v2.0/seasons/17420?api_token={API_TOKEN}&include=rounds.fixtures

Request 3 is used when you want to request the fixtures of a specific round id.

In this example, the EPL only has one stage, but other leagues may have multiple stages. In that case, we suggest you use the following request:

https://soccer.sportmonks.com/api/v2.0/seasons/17420?api_token={API_TOKEN}&include=stages.rounds.fixtures.localTeam,stages.rounds.fixtures.visitorTeam

Your request may be too big, if that's the case, pagination will kick in. You can refer to our Pagination tutorial for more information

Our Football API 2.0 has now given you the data of every round of the English Premier League and every fixture per round. This is the data you need to create the seasonal fixture schedule of the English Premier League.

In step 3, we’re going to show you how you can do the same for the Champions League, which will be significantly harder because the Champions League works with rounds, groups and stages.

Step 3: Request the Champions League stages

Let's take a look at the Champions League season 20/21 (season id: 17299). We start from a top position. We first request all the stages and can then work-out all the fixtures per stage and group.

https://soccer.sportmonks.com/api/v2.0/seasons/17299?api_token={API_TOKEN}&include=stages

We can see that the Champions League has the following stages:

  • Preliminary round - Semi-finals

  • Preliminary round - Final

  • 1st Qualifying round

  • 2nd Qualifying round

  • 3rd Qualifying round

  • Play-offs

  • Group Stage

  • 8th Finals

  • Quarter-finals

  • Semi-finals

  • Final

Requesting the fixtures

While, yes, we can use the nested include.fixturesagain. This would result in a huge, hard to read response. You can see for yourself with the following request that will give you an overview of everything about the Champions League:

https://soccer.sportmonks.com/api/v2.0/seasons/17299?api_token={API_TOKEN}&include=stages.rounds.fixtures.localTeam,stages.rounds.fixtures.visitorTeam

Instead, we will use the get stage by id endpoint with fixtures as include:

https://soccer.sportmonks.com/api/v2.0/stages/77447942?api_token={API_TOKEN}&include=fixtures.localTeam,fixtures.visitorTeam

This will request all the fixtures of the preliminary round - semi-finals (stage id #77447942). You can repeat this step for all the other stages, except for the group stages. Because there are eight groups (A-H), we want to subdivide this stage (stage id #77448760) into their respective groups. We use the nested include groups.fixtures:

https://soccer.sportmonks.com/api/v2.0/stages/77448760?api_token={API_TOKEN}&include=groups.fixtures

This request will give you the standings too for each respective group and all the fixtures of that group.

Knock-out stages

The Champions League also have a lot of knock out fixtures. The team who has the better result over two matches will go to the next stage. But how do you know what the overall result is?

You can use the aggregate include on fixtures level. This will show you the overall result between fixtures. Let's take a look at an example: Juventus vs Porto (second leg).

https://soccer.sportmonks.com/api/v2.0/fixtures/17687749?api_token={API_TOKEN}&include=aggregate

As you can see in the response, the overall result was 4-4 and the winner of this match is FC Porto(id:652). When you include aggregate.fixtures it will also include the information about the first fixture.

Last updated