Search⌘ K

Get a Random Cocktail

Explore how to retrieve a random cocktail recipe using TheCocktailDB API. Learn to make a simple API call that returns a complete cocktail recipe, including ingredients, preparation steps, glass type, and additional details, to help you decide what to drink.

There are times when we want to drink something but are not sure what we should go for. This is the kind of situation where we can use this endpoint to get the recipe for a random cocktail. The base URI of this endpoint is https://www.thecocktaildb.com/api/json/v1/1/random.php.

Query parameter

This endpoint does not require any query parameter.

Search for a random cocktail

We simply call the base URI to get a random cocktail. The code below shows how we can call this endpoint.

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

We’ll get the following data in response:

  • Instructions to create the cocktail
  • Link to an image of the cocktail
  • Image attribution
  • Category of the cocktail
  • Ingredients required
  • Amounts of ingredients
  • Glass type
  • Tags
  • Drink ID
  • Drink specification (Alcoholic/Non-Alcoholic)
  • Name of the drink
  • Last modified date of the recipe
  • License (Yes/No)
  • Video