Support Endpoints
Learn about the support endpoints that fetch parameters' information from the Api-Football database.
We'll cover the following
This lesson will briefly discuss endpoints used to get information that we can use with other endpoints. We can use this information to set the query parameters of the other endpoints. These endpoints include the following:
- Timezone
- Countries
- Leagues
- Rounds
We’ll look at each one of these endpoints to learn where and how we can use them.
The Timezone endpoint provides the list of available time zones. These time zones are used as a query parameter with the Fixtures endpoint. The base URL for this endpoint is https://v3.football.api-sports.io/timezone
. It contains all the existing time zones, so it doesn’t need to be updated.
This endpoint doesn't have any request parameters.
The widget below contains the code for listing time zones. Click the “Run” button to get the list of the available time zones.
const endpointUrl = new URL('https://v3.football.api-sports.io/timezone');headerParameters = {'x-rapidapi-host': 'v3.football.api-sports.io','x-rapidapi-key': '{{API_KEY}}'}const options = {method: 'GET',headers: headerParameters};async function fetchAvailableTimezones() {try {const response = await fetch(endpointUrl, options);printResponse(response);}catch (error) {printError(error);}}fetchAvailableTimezones();
We get the list of available time zones in response.
Countries endpoint
The Countries endpoint provides the list of available countries. The base URL for this endpoint is https://v3.football.api-sports.io/countries
.
We can use each of these parameters as a query parameter in our request to get the country’s information:
Request parameters
Parameters | Type | Category | Description |
| String | Optional | This is the |
| String | Optional | This is the |
| String | Optional | This contains the beginning initials of the name of the country we want to search for. A minimum of three characters are required. |
The code below will display the information of the country searched using the search
parameter. Click the “Run” button to get the required information.
const endpointUrl = new URL('https://v3.football.api-sports.io/countries');const queryParameters = new URLSearchParams({search: 'eng'});headerParameters = {'x-rapidapi-host': 'v3.football.api-sports.io','x-rapidapi-key': '{{API_KEY}}'}const options = {method: 'GET',headers: headerParameters};async function fetchAvailableCountries() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);printResponse(response);}catch (error) {printError(error);}}fetchAvailableCountries();
We get the code
, name
, and link for the image of the country’s flag. We can change the value of search
in line 4 to get information for other countries.
We can also change the query parameter to code
or name
by replacing search
with these parameters in line 4. We can even get the list of all available countries by using just the base URL as the endpointURL
.
Leagues endpoint
The Leagues endpoint provides the list of available leagues and cups. The base URL for this endpoint is https://v3.football.api-sports.io/leagues
.
The query parameters for the Leagues endpoint are as follows:
Request parameters
Parameters | Type | Category | Description |
| Integer | Optional | This is the ID of the league we want to search for. |
| Integer | Optional | This is the ID of the team we want to search for. |
| String | Optional | This is the name of the league. |
| String | Optional | This contains the initials of the league we want to search for. It should be a minimum of three characters. |
| String | Optional | This is the country name of the league. Calling the endpoint results in an error if the field contains anything other than alpha-numeric characters, underscores, or dashes. |
| String | Optional | This is the code of the country. This string should consist of two characters. |
| Integer | Optional | This is the year we want to see the stats for. The format for this field is "YYYY". |
| String | Optional | This shows the state of the league. This parameter should be |
| String | Optional | This parameter shows whether we're searching for a league or a cup. Its value should be |
| Integer | Optional | This parameter shows X last leagues/cups added in the API. |
The code below displays the information of the leagues filtered by name. Click the “Run” button to get the required information.
const endpointUrl = new URL('https://v3.football.api-sports.io/leagues');const queryParameters = new URLSearchParams({name: 'premier league'});headerParameters = {'x-rapidapi-host': 'v3.football.api-sports.io','x-rapidapi-key': '{{API_KEY}}'}const options = {method: 'GET',headers: headerParameters};async function fetchAvailableLeagues() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);printResponse(response);}catch (error) {printError(error);}}fetchAvailableLeagues();
We get the league’s information, the corresponding country’s information, along with the statistics available for the league. We can get information for other leagues by replacing premier league
in line 4 with the name of the other league.
We can also use other query parameters instead of name
in line 4. To get the list of all available leagues, use the base URL as the endpointURL
. We can also make requests by mixing the available parameters.
Rounds endpoint
The Rounds endpoint provides the rounds of a league or a cup. We can use these rounds as query parameters for the Fixtures endpoint. The base URL for this endpoint is https://v3.football.api-sports.io/fixtures/rounds
.
The query parameters for this endpoint are as follows:
Request parameters
Parameters | Type | Category | Description |
| Integer | Required | This is the ID of the league, which can be obtained using the Leagues endpoint, as described above. |
| Integer | Required | This is the year we want to see the stats for. The format for this field is "YYYY". |
| String | Optional | This shows the state of the league. This parameter should be |
The code in the widget below shows how we can use GET
requests for this endpoint. season
in line 4, league
in line 5, and current
in line 6 are used as query parameters. Click the “Run” button to get the rounds of the league information.
const endpointUrl = new URL('https://v3.football.api-sports.io/fixtures/rounds');const queryParameters = new URLSearchParams({season: '2019',league: '39', // 39 is the league id for England's Premier Leaguecurrent: 'FALSE'});headerParameters = {'x-rapidapi-host': 'v3.football.api-sports.io','x-rapidapi-key': '{{API_KEY}}'}const options = {method: 'GET',headers: headerParameters};async function fetchAvailableCountries() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);printResponse(response);}catch (error) {printError(error);}}fetchAvailableCountries();
We get the rounds for the corresponding league as the response to this GET
request. We can change the data in lines 4-6 to get information for other leagues and seasons.