Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import requests
import json
headers = {
'x-rapidapi-host': "the-cocktail-db.p.rapidapi.com",
#your API key
}
def httpRequest(pathname, params=()):
url = "https://the-cocktail-db.p.rapidapi.com" + pathname
response = requests.request("GET", url, headers=headers, params=params)
return json.loads(response.text)
def getRandomCocktail():
return httpRequest('/random.php')
def getIngredients():
params = {"i": 'list'}
return httpRequest('/list.php?i=list', params=params)
def getCocktailByIngredient(ingredient):
params = {"i":ingredient}
return httpRequest('/filter.php',params=params)
def getCocktailByName(name):
params = {"s":name}
return httpRequest('/search.php',params=params)