Request and Response Structure
Learn the request and response structure of TheMealDB API.
We'll cover the following
Request structure
The request for TheMealDB API contains the endpoint the user wants to call. Each endpoint serves a different function. Here is the list of the base URLs which can be used:
Function | Base URL |
List all categories, cuisines or ingredients |
|
Filter meals by categories, cuisines, or ingredients |
|
Lookup meal details or ingredient by ID |
|
Search meals by first letter or name |
|
Lookup a random meal |
|
Note: The API key
1
afterwww.themealdb.com/api/json/v1/
in each of these addresses is the development API that is used for authentication.
These endpoints are combined with the query parameters to get the data we want.
Response structure
The response structure will differ depending on whether our search criteria matched any meal from the DB or not.
In case of an unsuccessful request
If our search criteria do not match any meal in the DB, the result will contain only one element, i.e., meals
. The value of meals
will be null
.
In case of a successful request
For a successful request, we’ll get different data for different endpoints. We’ll discuss the results of successful requests for these endpoints in detail in the upcoming lessons.