TheCocktailDB API
www.thecocktaildb.com · Food
Free cocktail recipe database — search by name, ingredient, or category. Returns ingredients, measurements, instructions, and photos. No API key for basic use.
Authentication
No authentication requiredFree to use with no key needed.
Sample Requests
GET
Search cocktails
Search for margarita cocktail recipes.
https://www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita
Hover any highlighted part to learn what it does
curl -X GET "https://www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita"
import requests
params = {
"s": "margarita"
}
response = requests.get(
"https://www.thecocktaildb.com/api/json/v1/1/search.php",
params=params,
)
print(response.json())const url = new URL('https://www.thecocktaildb.com/api/json/v1/1/search.php');
url.searchParams.set('s', 'margarita');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://www.thecocktaildb.com/api/json/v1/1/search.php")
q := baseURL.Query()
q.Set("s", "margarita")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://www.thecocktaildb.com/api/json/v1/1/search.php")
uri.query = URI.encode_www_form({
"s" => "margarita"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://www.thecocktaildb.com/api/json/v1/1/search.php?" . http_build_query([
"s" => "margarita"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Random cocktail
Get a random cocktail recipe.
https://www.thecocktaildb.com/api/json/v1/1/random.php
Hover any highlighted part to learn what it does
curl -X GET "https://www.thecocktaildb.com/api/json/v1/1/random.php"
import requests
response = requests.get(
"https://www.thecocktaildb.com/api/json/v1/1/random.php",
)
print(response.json())const url = 'https://www.thecocktaildb.com/api/json/v1/1/random.php'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://www.thecocktaildb.com/api/json/v1/1/random.php"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://www.thecocktaildb.com/api/json/v1/1/random.php")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://www.thecocktaildb.com/api/json/v1/1/random.php";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- No API key — use "1" in URL
- Search: GET /api/json/v1/1/search.php?s=mojito
- By ingredient: GET /api/json/v1/1/filter.php?i=vodka
- Random: GET /api/json/v1/1/random.php
- Categories: GET /api/json/v1/1/list.php?c=list