Players Statistics

Learn how to get player statistics for a fixture.

Some players don’t seem to be too effective in a match, but when we look at the underlying statistics of the player after the game, we feel otherwise. We can get these player statistics using Api-Football.

Retrieve player stats from fixtures

We use the Player statistics endpoint to get a player’s statistics from a fixture. We’ll get the minutes played, position, rating, offsides, shots, goals, passes, tackles, duels, dribbles, fouls, cards, and penalties for the player. The basic URI of this endpoint is https://v3.football.api-sports.io/fixtures/players. This endpoint is updated every minute.

Request parameters

The query parameters for this endpoint are as follows:

Parameters

Type

Category

Description

fixture

Integer

Required

This is the ID of the fixture for which we want the stats. We can get the ID of the fixture using the Fixtures endpoint.

team

Integer

Optional

This is the ID of the team we want the stats to be related to. We can get the ID of the team using the Teams endpoint.

We use the fixture parameter with the Players Statistics endpoint to get all the players’ statistics from a fixture. Click the “Run” button to get the players’ statistics.

Press + to interact
const endpointUrl = new URL('https://v3.football.api-sports.io/fixtures/players');
const queryParameters = new URLSearchParams({
fixture: '169080' // 169080 is the fixture id for the match between
// Monarcas and Atlas, which took place on 2019-07-27
});
headerParameters = {
'x-rapidapi-host': 'v3.football.api-sports.io',
'x-rapidapi-key': '{{API_KEY}}'
}
const options = {
method: 'GET',
headers: headerParameters
};
async function fetchPlayersStats() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
printResponse(response);
}
catch (error) {
printError(error);
}
}
fetchPlayersStats();

Here is the code explanation:

  • Line 1: We set the URL to https://v3.football.api-sports.io/fixtures/players.

  • Lines 3–11: We define the query parameters and header parameters. We can change the fixture ID in line 4 to get stats from another fixture.

  • Lines 13–16: We set the request type and appropriate header.

  • Lines 18–27: We define a function, fetchPlayerStats(). It calls the endpoint and prints the response.

Note: We can use the Fixtures endpoint to get the fixture’s ID, as explained in the Fixtures Information lesson.

Using both the team parameter and the fixture parameter for this endpoint will filter the data received previously such that we’ll only get the player statistics for a single team. Click the “Run” button to initiate the GET request and see the output.

Press + to interact
const endpointUrl = new URL('https://v3.football.api-sports.io/fixtures/players');
const queryParameters = new URLSearchParams({
fixture: '169080', // 169080 is the fixture id for the match between
// Monarcas and Atlas, which took place on 2019-07-27
team: '2284' // 2284 is the team id for Maonarcas
});
headerParameters = {
'x-rapidapi-host': 'v3.football.api-sports.io',
'x-rapidapi-key': '{{API_KEY}}'
}
const options = {
method: 'GET',
headers: headerParameters
};
async function fetchPlayersStats() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
printResponse(response);
}
catch (error) {
printError(error);
}
}
fetchPlayersStats();

We’ve added the team query parameter in line 6 to filter the response we got from the previous widget. We can get the statistics for the other team by changing the team ID in line 6.

Note: We can use the Teams information endpoint to get the team’s ID, as explained in the Teams Information lesson.

Response fields

The table below contains some important response fields of this endpoint:

Response Fields

Type

Description

team

Object

This is the team whose fixture stats are listed.

players

Object [array]

This array contains the players' information and stats. It has the following two elements:

  • player: It contains the ID, name, and link for a photo of the player.
  • statistics: It is an array of objects that contains the player's stats. Its details are in the Response Elements lesson of the Appendix.