Dishes_DB 外部接入说明
生成时间:2026-06-03
这份文档只保留外部应用对接需要的内容。拿到 Base URL、API Key 和这份说明,就可以直接调用。
1. 基础信息
- Base URL:
https://apidishes.aiugc.ai - 认证头:
x-api-key
2. 接入方式
外部应用通常只需要这三样:
- Base URL
- API Key
- API 说明文件
请求头示例:
Content-Type: application/json
x-api-key: your_api_key
3. 查询入口
3.1 分类结构树
GET /api/categories/tree
用途:
- 获取菜色大类与分类树状结构
响应示例:
{
"items": [
{
"foodstyle": "1",
"total": 320,
"cuisines": [
{ "cuisine": "01", "count": 56 }
]
}
]
}
3.2 按菜色名称查询
GET /api/dishes/by-name?name=土豆烧肉
用途:
- 通过菜色名称获取该菜色的完整详细信息
- 这是唯一会返回单笔详细资料的名称查询
响应示例:
{
"id": "20708",
"foodstyle": "1",
"cuisine": "01",
"image": "/assets/Dishes_pic/207/20708_s.jpg",
"images": {
"small": "/assets/Dishes_pic/207/20708_s.jpg",
"large": "/assets/Dishes_pic/207/20708_l.jpg",
"original": "/assets/Dishes_pic/207/20708.jpg"
},
"data": {
"name": "土豆烧肉"
}
}
3.3 按食材名称查询
GET /api/dishes/by-ingredient?name=土豆
用途:
- 通过食材名称查菜色
- 返回最多 3 道菜
响应示例:
{
"total": 12,
"items": [
{ "id": "20708", "name": "土豆烧肉", "foodstyle": "1", "cuisine": "01" }
]
}
3.4 获取烹调方式列表及编号
GET /api/cooking-methods
用途:
- 获取所有烹调方式的名称与编号
响应示例:
{
"total": 11,
"items": [
{ "code": "01", "name": "炒" },
{ "code": "02", "name": "炸" },
{ "code": "03", "name": "炖" },
{ "code": "04", "name": "拌" },
{ "code": "05", "name": "蒸" },
{ "code": "06", "name": "煎" },
{ "code": "07", "name": "烤" },
{ "code": "08", "name": "煮" },
{ "code": "09", "name": "生食" },
{ "code": "10", "name": "冷制" },
{ "code": "13", "name": "冷藏" }
]
}
3.5 按烹调方式查询
GET /api/dishes/by-cooking-method?code=05
用途:
- 通过烹调方式编号查菜色
- 返回最多 3 道菜
响应示例:
{
"method": { "code": "05", "name": "蒸" },
"total": 18,
"items": [
{ "id": "20404", "name": "明太子麻糬文字烧", "foodstyle": "2", "cuisine": "03" }
]
}
3.6 获取特殊人群列表及编号
GET /api/audiences
用途:
- 获取特殊人群的名称与编号
响应示例:
{
"total": 42,
"items": [
{ "code": "01", "name": "一般" },
{ "code": "02", "name": "高血压" },
{ "code": "03", "name": "糖尿病" }
]
}
3.7 按特殊人群查询
GET /api/dishes/by-audience?code=03&kind=applicable
用途:
- 通过特殊人群编号查菜色
kind=applicable表示适用人群kind=banned表示禁忌人群- 返回最多 3 道菜
响应示例:
{
"crowd": { "code": "03", "name": "糖尿病" },
"kind": "applicable",
"total": 6,
"items": [
{ "id": "10112", "name": "清蒸鲈鱼", "foodstyle": "1", "cuisine": "01" }
]
}
3.8 按菜色 ID 查询
GET /api/dishes/:id
用途:
- 直接按菜色 ID 取得完整详情
4. 返回规则
GET /api/dishes/by-name只返回该菜色的完整详细信息- 其他查询接口最多返回 3 道菜
- 不足 3 道时,返回实际可找到的数量
- 列表接口通常会带
total与items
5. 范例代码
cURL
curl "https://apidishes.aiugc.ai/api/dishes/by-name?name=土豆烧肉" ^
-H "x-api-key: your_api_key"
curl "https://apidishes.aiugc.ai/api/dishes/by-ingredient?name=土豆" ^
-H "x-api-key: your_api_key"
curl "https://apidishes.aiugc.ai/api/dishes/by-cooking-method?code=***" ^
-H "x-api-key: your_api_key"
curl "https://apidishes.aiugc.ai/api/dishes/by-audience?code=***&kind=applicable" ^
-H "x-api-key: your_api_key"
JavaScript / fetch
const baseURL = "https://apidishes.aiugc.ai";
const apiKey = "your_api_key";
async function getDishesByIngredient(name) {
const res = await fetch(`${baseURL}/api/dishes/by-ingredient?name=${encodeURIComponent(name)}`, {
headers: { "x-api-key": apiKey }
});
return await res.json();
}
getDishesByIngredient("土豆").then(console.log);
async function getDishByName(name) {
const res = await fetch(`${baseURL}/api/dishes/by-name?name=${encodeURIComponent(name)}`, {
headers: { "x-api-key": apiKey }
});
return await res.json();
}
Python / requests
import requests
BASE_URL = "https://apidishes.aiugc.ai"
API_KEY = "your_api_key"
headers = {"x-api-key": API_KEY}
resp = requests.get(
f"{BASE_URL}/api/dishes/by-audience",
params={"code": "03", "kind": "applicable"},
headers=headers,
)
print(resp.json())
6. 常见错误
401
- 没有带
x-api-key - API Key 无效
- API Key 被停用
404
- 菜色不存在
- 食材不存在
- 烹调方式不存在
- 特殊人群不存在
7. 备注
- 当前服务主入口是
service/server.js - 当前文档页地址是
/api-readme - 旧管理后台内容不在这份外部说明里