Search⌘ K
AI Features

Get a Random Meal

Explore how to use TheMealDB API to retrieve a random meal recipe. Learn to access meal ingredients, cooking instructions, and other key details without needing query parameters. This lesson helps you provide users with spontaneous meal ideas effectively.

Sometimes, the user might not know what to cook. This is where we can use this endpoint to give the user the recipe for a random meal. The base URI of this endpoint is https://www.themealdb.com/api/json/v1/1/random.php.

Query parameter

This endpoint does not require any query parameters.

Search for the recipe of a random meal

The code below shows how we can call this endpoint to get the recipe for a random meal.

Python
import json
import requests
url=('https://www.themealdb.com/api/json/v1/1/random.php')
response = requests.request("GET", url).json()
print(json.dumps(response, indent=4))

We’ll get the following information in response:

  • Ingredients required
  • Instructions to create a meal
  • Amounts of ingredients
  • Name of the meal
  • Database ID
  • Category
  • Cuisine
  • Link for an image of the meal
  • Video
  • Database tags
  • Last modified date
  • License