Request and Response Structure

Let's look at the generic request and response structure for the endpoints.

Request structure

The request of an Api-Football endpoint contains a header and an endpoint.

Header structure

The header contains two elements:

  • x-rapidapi-host is either v3.football.api-sports.io or api-football-v1.p.rapidapi.com, depending on the platform you’ve signed up with. In our case, it’ll be v3.football.api-sports.io since we signed up using the Api-Football website.
  • x-rapidapi-key is the API key of the user.

Endpoint structure

The endpoint consists of the base URI and query parameters, depending on the endpoint the user is trying to access.

Response structure

The response contains a header and a JSON response object.

Header structure

The header contains four elements:

  • x-ratelimit-requests-limit tells the user about the number of requests allocated per day according to our subscription.

  • x-ratelimit-requests-remaining provides information about the number of remaining requests per day according to our subscription.

  • x-ratelimit-limit contains the maximum number of API calls per minute.

  • x-ratelimit-remaining tells the user about the number of API calls remaining before reaching the limit per minute.

The JSON response

The JSON element of the response provides the user with the required information for which the endpoint was called. The information is different for different endpoints. We’ve looked at the response parameters for each endpoint in the previous lessons.

The user may receive an error message in the response, which will look something like this:

Press + to interact
"errors": {
"token": "Error/Missing application key. Go to https://www.api-football.com/documentation-v3 to learn how to get your API application key."
}

Note: With the free subscription, you’re allowed 100 requests per day. After that, you’ll receive the above error message in response.