Request and Response Structure
Let's look at the generic request and response structure for the endpoints.
We'll cover the following...
Request structure
The request of an Api-Football endpoint contains a header and an endpoint.
Header structure
The header contains two elements:
x-rapidapi-hostis eitherv3.football.api-sports.ioorapi-football-v1.p.rapidapi.com, depending on the platform you’ve signed up with. In our case, it’ll bev3.football.api-sports.iosince we signed up using the Api-Football website.x-rapidapi-keyis 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-limittells the user about the number of requests allocated per day according to our subscription. -
x-ratelimit-requests-remainingprovides information about the number of remaining requests per day according to our subscription. -
x-ratelimit-limitcontains the maximum number of API calls per minute. -
x-ratelimit-remainingtells 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:
"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.