Request and Response Structure

Learn the request and response structure of TheMealDB API.

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

www.themealdb.com/api/json/v1/1/list.php

Filter meals by categories, cuisines, or ingredients

www.themealldb.com/api/json/v1/1/filter.php

Lookup meal details or ingredient by ID

www.themealldb.com/api/json/v1/1/lookup.php

Search meals by first letter or name

www.themealldb.com/api/json/v1/1/search.php

Lookup a random meal

www.themealldb.com/api/json/v1/1/random.php

Note: The API key 1 after www.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.