Fixtures Information
Learn how to use the Fixtures endpoint to get information about fixtures.
We'll cover the following
As football fans, we’d like to organize our schedule so that we don’t miss any of our favorite team’s games. Api-Football can supply us with upcoming football fixtures to assist us in staying on track. And it’s not only limited to the future fixtures; we can also get information about prior and current games.
Retrieve a list of fixtures
To retrieve information about fixtures using Api-Football, we use the Fixtures endpoint. The base URI for this endpoint is https://v3.football.api-sports.io/fixtures
.
Request parameters
Following are the query parameters for the Fixtures endpoint:
Parameters | Type | Category | Description |
| Integer | Optional | This is the ID of the fixture. |
| String | Optional | The value of this parameter will be |
| String | Optional | This is the date of the fixture we want to see. The format is "YYYY-MM-DD." |
| Integer | Optional |
|
| Integer | Optional | This is the year we want to see the fixtures for. The format is "YYYY." |
| Integer | Optional | This is the ID of the team we want fixtures for. This ID can be obtained using the Teams information endpoint. |
| Integer | Optional | This indicates the number of past fixtures we want to see the stats for. It should be a two-digit integer. |
| Integer | Optional | This indicates the number of future fixtures we want to see the information for. It should be a two-digit integer. |
| String | Optional | This is the date we want the fixtures' data to begin from. The format is "YYYY-MM-DD." |
| String | Optional | This is the termination date for the fixtures' data. The format is "YYYY-MM-DD." |
| String | Optional | This is the round number of the fixture we want to see the stats for. The number of rounds can be obtained from the Rounds endpoint as explained in the "Support Endpoints" lesson of the Appendix. |
| String | Optional | This indicates the status of the fixtures. |
| String | Optional | This is the time zone we want to see the fixtures for. Valid time zones can be obtained using the Timezone endpoint as explained in the "Support Endpoints" lesson of the Appendix. |
Note: To look at the list of valid statuses for this endpoint, click
here. UntitledConcept1
We can use the team
and season
parameters with the Fixtures endpoints to get fixtures for a specific team. Click the “Run” button to retrieve the information for a specific fixture.
const date = new Date();const endpointUrl = new URL('https://v3.football.api-sports.io/fixtures');const queryParameters = new URLSearchParams({team: '33', // 33 is the team id for Manchester Unitedseason: date.getFullYear()});headerParameters = {'x-rapidapi-host': 'v3.football.api-sports.io','x-rapidapi-key': '{{API_KEY}}'}const options = {method: 'GET',headers: headerParameters};async function fetchTeamFixtures() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);printResponse(response);}catch (error) {printError(error);}}fetchTeamFixtures();
Here is a brief code explanation:
Line 2: We set the URL to
https://v3.football.api-sports.io/fixtures
.Lines 4–12: We define the query parameters and header parameters. We can get fixtures for other teams by changing the team ID in line 5.
Lines 14–17: We set the request type and appropriate header.
Lines 19–28: We define a function,
fetchTeamFixtures()
. It calls the endpoint and prints the response.
Note: The team ID can be retrieved using the Teams information endpoint, as explained in Teams Information lesson.
To get the list of live fixtures, we use the live
parameter with the Fixtures endpoint. The value of the live
parameter will be all
. The widget below shows how this endpoint is used to retrieve a list of live fixtures. Click the “Run” button to see the response.
const endpointUrl = new URL('https://v3.football.api-sports.io/fixtures');const queryParameters = new URLSearchParams({live: 'all'});headerParameters = {'x-rapidapi-host': 'v3.football.api-sports.io','x-rapidapi-key': '{{API_KEY}}'}const options = {method: 'GET',headers: headerParameters};async function fetchLiveFixtures() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);printResponse(response);}catch (error) {printError(error);}}fetchLiveFixtures();
Let's look at the code modifications:
Lines 3–5: We change the query parameters. We can change the league ID in line 4 to get fixtures for other leagues.
Line 17: We change the function's name to
fetchLiveFixtures()
.
We can get a league’s fixtures by replacing all
in line 4 with the ID of the league. To get fixtures of multiple leagues, we’ll replace all
with the IDs of the leagues, separated by -
.
Let’s get the fixtures for EPL and Ligue 1 by replacing all
in line 4 with 33-61
. Click the “Run” button after making the changes in code to get the fixtures for these leagues.
Note: The league ID can be retrieved using the Leagues endpoint, as explained in the Support Endpoints lesson in the Appendix.
Response fields
The table below contains some important response fields of this endpoint:
Response fields | Type | Description |
| Object | This object contains information like ID, date, and time of the fixtures. |
| Object | This object contains information about the league in which the fixture has been scheduled. |
| Object | This object contains information about the ID, name, and a link for the logo of the teams participating in the fixture. |
| Object | This object contains information about the goals scored in the fixture. |
| Object | This object contains information about the goals scored at half-time, full-time, extra-time, and the goals scored in penalties. |
Note: The details about the elements of the
fixture
andleague
objects are discussed in the Response Elements lesson in the Appendix.