Fetch the List of Available Filters

Learn how to get the lists of available categories, cuisines, and ingredients available in the database.

We get the lists of items that we can use to filter the meals using the base URI https://www.themealdb.com/api/json/v1/1/list.php.

This endpoint provides three types of lists, which are as follows:

  1. Categories list
  2. Cuisines list
  3. Ingredients list

We’ll look at how to get these lists in this lesson.

Query parameters

We can use any one of the following query parameters with this endpoint:

Parameters

Type

Category

Description

c

string

optional

This parameter is used to get all the available categories.

a

string

optional

This parameter is used to get the list of available cuisines.

i

string

optional

This parameter gives us all the available ingredients from the database.

We need to use at least one of these parameters with this endpoint. Calling it without any query parameters will return an error.

Get all the categories

The query parameter c is used to get the list of available categories. The value assigned to c will be list.

The widget below contains the code which fetches this list.

Press + to interact
import json
import requests
url=('https://www.themealdb.com/api/json/v1/1/list.php?c=list')
response = requests.request("GET", url).json()
print(json.dumps(response, indent=4))

We get the list of all available categories in response.

Get the list of available cuisines

The query parameter a, when combined with https://www.themealdb.com/api/json/v1/1/list.php, provides us the list of available cuisines in the database. The value of a is list.

The code below demonstrates how we can get the list of available cuisines.

Press + to interact
import json
import requests
url=('https://www.themealdb.com/api/json/v1/1/list.php?a=list')
response = requests.request("GET", url).json()
print(json.dumps(response, indent=4))

We get the list of all available cuisines in response.

Get the list of available ingredients

The query parameter i, when combined with https://www.themealdb.com/api/json/v1/1/list.php, provides us with the list of available ingredients in the database. The value of i is list.

The code below demonstrates how we can get the list of available ingredients.

Press + to interact
import json
import requests
url=('https://www.themealdb.com/api/json/v1/1/list.php?i=list')
response = requests.request("GET", url).json()
print(json.dumps(response, indent=4))

We get the type, name, ID, and description of the available ingredients in response.