TheMealDB and TheCocktailDB APIs Overview
Get familiarized with TheMealDB and TheCocktailDB APIs.
We'll cover the following
TheMealDB API
TheMealDB is a free API that provides access to an online database of meal recipes. We can use it to query a database of hundreds of meals. We can search for recipes, images of specific meals, ingredients, and much more. It provides the required information as a JSON object. The illustration below shows the functionalities of the endpoints that we'll discuss:
TheCocktailDB API
TheCocktailDB API allows us to access an online database of cocktail recipes. Just like TheMealDB API, it is free to use. We can use it to get cocktail recipes, cocktail images, and so on. Its response is also in the form of a JSON object. The functionalities and base URLs of the endpoints that we'll discuss are mentioned in the table below:
We can use 1
as the API key for authentication when using these APIs for development or educational purposes. However, we’ll need to sign up as a Patreon supporter if we want to release our application publicly. Since we’re just learning about these APIs in this course, we’ll keep things simple and use 1
for authentication.
Fetch a breakfast recipe
Let’s get a glimpse of what we can fetch using these APIs. The widget below uses hidden code to call an endpoint of TheMealDB API. We retrieve a breakfast recipe in JSON format and print the returned image, name, and recipe.
fetchBreakfast(); // A function that calls the API and prints the fetched image and name