饮料酒品
其他 官方文档
查询来自世界各地的饮料和鸡尾酒
基本说明:
接口地址:https://www.thecocktaildb.com/api/json/v1/1/search.php
返回格式:json
请求方式:get/post
请求示例:https://www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita
请求参数说明:
名称 类型 必填 说明
s string 选填 饮料酒品名称
返回参数说明:
名称 类型 说明
- - 见json
JSON返回示例:
{
	"drinks": [{
		"idDrink": "178332",
		"strDrink": "Smashed Watermelon Margarita",
		"strDrinkAlternate": null,
		"strTags": null,
		"strVideo": null,
		"strCategory": "Cocktail",
		"strIBA": null,
		"strAlcoholic": "Alcoholic",
		"strGlass": "Collins glass",
		"strInstructions": "In a mason jar muddle the watermelon and 5 mint leaves together into a puree and strain. Next add the grapefruit juice, juice of half a lime and the tequila as well as some ice. Put a lid on the jar and shake. Pour into a glass and add more ice. Garnish with fresh mint and a small slice of watermelon.",
		"strInstructionsES": null,
		"strInstructionsDE": null,
		"strInstructionsFR": null,
		"strInstructionsIT": "In un barattolo di vetro pestare l'anguria e 5 foglie di menta insieme, filtrare il contenuto in un bicchiere. Quindi aggiungere il succo di pompelmo, il succo di mezzo lime, la tequila e un po 'di ghiaccio. Metti un coperchio sul barattolo e agita. Versare in un bicchiere e aggiungere altro ghiaccio. Guarnire con menta fresca e una fettina di anguria.",
		"strInstructionsZH-HANS": null,
		"strInstructionsZH-HANT": null,
		"strDrinkThumb": "https:\/\/www.thecocktaildb.com\/images\/media\/drink\/dztcv51598717861.jpg",
		"strIngredient1": "Watermelon",
		"strIngredient2": "Mint",
		"strIngredient3": "Grapefruit Juice",
		"strIngredient4": "Lime",
		"strIngredient5": "Tequila",
		"strIngredient6": "Watermelon",
		"strIngredient7": "Mint",
		"strIngredient8": null,
		"strIngredient9": null,
		"strIngredient10": null,
		"strIngredient11": null,
		"strIngredient12": null,
		"strIngredient13": null,
		"strIngredient14": null,
		"strIngredient15": null,
		"strMeasure1": "1\/2 cup",
		"strMeasure2": "5",
		"strMeasure3": "1\/3 Cup",
		"strMeasure4": "Juice of 1\/2",
		"strMeasure5": "1 shot",
		"strMeasure6": "Garnish with",
		"strMeasure7": "Garnish with",
		"strMeasure8": null,
		"strMeasure9": null,
		"strMeasure10": null,
		"strMeasure11": null,
		"strMeasure12": null,
		"strMeasure13": null,
		"strMeasure14": null,
		"strMeasure15": null,
		"strImageSource": null,
		"strImageAttribution": null,
		"strCreativeCommonsConfirmed": "No",
		"dateModified": null
	}]
}
服务级错误码参照
错误码 说明
- -
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2023/11/10 14:26
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita"
)

func main() {
	queryUrl := fmt.Sprintf("%s",APIURL)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}