{
    "openapi": "3.0.0",
    "info": {
        "title": "营养成分表 - API文档",
        "version": "1.0.0",
        "description": "查询近两千种常见食物详细的营养成分及100克下的微量元素含量、支持食品种类检索和成分含量排序。注意mode参数，为0时搜索食品的营养成分含量（例如油条、黄瓜），为1是搜索食品分类（例如谷类、水果类），为2为搜索营养成分含量排名从高到低（例如热量rl、钙含量gai），为3就是成分含量从低到高。具体种类和成分表及其单位请参考<a href=\"https:\/\/www.tianapi.com\/article\/110\" target=\"_blank\">食品种类和营养成分表<\/a>。"
    },
    "servers": [
        {
            "url": "https:\/\/apis.tianapi.com"
        }
    ],
    "paths": {
        "\/nutrient\/index": {
            "get": {
                "summary": "营养成分含量查询",
                "tags": [
                    "营养成分表"
                ],
                "description": "查询食材的营养成份含量数据",
                "parameters": [
                    {
                        "name": "key",
                        "in": "query",
                        "description": "API密钥",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "description": "API密钥"
                        }
                    },
                    {
                        "name": "num",
                        "in": "query",
                        "description": "返回数量，默认10，最大20",
                        "required": false,
                        "schema": {
                            "type": "int",
                            "example": 10,
                            "description": "返回数量，默认10，最大20"
                        }
                    },
                    {
                        "name": "mode",
                        "in": "query",
                        "description": "搜索模式：0营养成分、1食品分类、2营养正序、3营养倒序",
                        "required": true,
                        "schema": {
                            "type": "int",
                            "example": 0,
                            "description": "搜索模式：0营养成分、1食品分类、2营养正序、3营养倒序"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "翻页",
                        "required": false,
                        "schema": {
                            "type": "int",
                            "example": 1,
                            "description": "翻页"
                        }
                    },
                    {
                        "name": "word",
                        "in": "query",
                        "description": "食品名称、类型名称、营养成分缩写",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "example": "油条",
                            "description": "食品名称、类型名称、营养成分缩写"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "la": {
                                            "type": "float",
                                            "example": 585.2,
                                            "description": "钠"
                                        },
                                        "lb": {
                                            "type": "float",
                                            "example": 2.7,
                                            "description": " 胡罗卜素"
                                        },
                                        "rl": {
                                            "type": "float",
                                            "example": 386,
                                            "description": "热量(大卡)"
                                        },
                                        "su": {
                                            "type": "float",
                                            "example": 0.07,
                                            "description": "核黄素"
                                        },
                                        "xi": {
                                            "type": "float",
                                            "example": 8.6,
                                            "description": "硒"
                                        },
                                        "ys": {
                                            "type": "float",
                                            "example": 0.7,
                                            "description": "烟酸"
                                        },
                                        "zf": {
                                            "type": "float",
                                            "example": 17.6,
                                            "description": "脂肪"
                                        },
                                        "dbz": {
                                            "type": "float",
                                            "example": 6.9,
                                            "description": "蛋白质"
                                        },
                                        "dgc": {
                                            "type": "float",
                                            "example": 0,
                                            "description": "胆固醇"
                                        },
                                        "gai": {
                                            "type": "float",
                                            "example": 6,
                                            "description": "钙(毫克)"
                                        },
                                        "jia": {
                                            "type": "float",
                                            "example": 227,
                                            "description": "钾"
                                        },
                                        "las": {
                                            "type": "float",
                                            "example": 0.01,
                                            "description": "硫胺素"
                                        },
                                        "mei": {
                                            "type": "float",
                                            "example": 19,
                                            "description": "镁"
                                        },
                                        "shc": {
                                            "type": "float",
                                            "example": 21.8,
                                            "description": "视黄醇当量"
                                        },
                                        "tei": {
                                            "type": "float",
                                            "example": 1,
                                            "description": "铁"
                                        },
                                        "xin": {
                                            "type": "float",
                                            "example": 0.75,
                                            "description": "锌"
                                        },
                                        "ling": {
                                            "type": "float",
                                            "example": 77,
                                            "description": "磷"
                                        },
                                        "meng": {
                                            "type": "float",
                                            "example": 0.52,
                                            "description": "锰"
                                        },
                                        "name": {
                                            "type": "string",
                                            "example": "油条",
                                            "description": "食品名称"
                                        },
                                        "shhf": {
                                            "type": "float",
                                            "example": 50.1,
                                            "description": "碳水化合物"
                                        },
                                        "ssxw": {
                                            "type": "float",
                                            "example": 0.9,
                                            "description": "膳食纤维"
                                        },
                                        "tong": {
                                            "type": "float",
                                            "example": 0.19,
                                            "description": "铜"
                                        },
                                        "type": {
                                            "type": "string",
                                            "example": "谷类",
                                            "description": "食品种类"
                                        },
                                        "wsfc": {
                                            "type": "float",
                                            "example": 0,
                                            "description": "维生素C"
                                        },
                                        "wssa": {
                                            "type": "float",
                                            "example": 0,
                                            "description": "维生素A"
                                        },
                                        "wsse": {
                                            "type": "float",
                                            "example": 3.19,
                                            "description": "维生素E"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "la": 585.2,
                                        "lb": 2.7,
                                        "rl": 386,
                                        "su": 0.07,
                                        "xi": 8.6,
                                        "ys": 0.7,
                                        "zf": 17.6,
                                        "dbz": 6.9,
                                        "dgc": 0,
                                        "gai": 6,
                                        "jia": 227,
                                        "las": 0.01,
                                        "mei": 19,
                                        "shc": 21.8,
                                        "tei": 1,
                                        "xin": 0.75,
                                        "ling": 77,
                                        "meng": 0.52,
                                        "name": "油条",
                                        "shhf": 50.1,
                                        "ssxw": 0.9,
                                        "tong": 0.19,
                                        "type": "谷类",
                                        "wsfc": 0,
                                        "wssa": 0,
                                        "wsse": 3.19
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "营养成分含量查询",
                "tags": [
                    "营养成分表"
                ],
                "description": "查询食材的营养成份含量数据",
                "requestBody": {
                    "content": {
                        "application\/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "API密钥"
                                    },
                                    "num": {
                                        "type": "int",
                                        "example": 10,
                                        "description": "返回数量，默认10，最大20"
                                    },
                                    "mode": {
                                        "type": "int",
                                        "example": 0,
                                        "description": "搜索模式：0营养成分、1食品分类、2营养正序、3营养倒序"
                                    },
                                    "page": {
                                        "type": "int",
                                        "example": 1,
                                        "description": "翻页"
                                    },
                                    "word": {
                                        "type": "string",
                                        "example": "油条",
                                        "description": "食品名称、类型名称、营养成分缩写"
                                    }
                                },
                                "required": [
                                    "key",
                                    "mode",
                                    "word"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "la": {
                                            "type": "float",
                                            "example": 585.2,
                                            "description": "钠"
                                        },
                                        "lb": {
                                            "type": "float",
                                            "example": 2.7,
                                            "description": " 胡罗卜素"
                                        },
                                        "rl": {
                                            "type": "float",
                                            "example": 386,
                                            "description": "热量(大卡)"
                                        },
                                        "su": {
                                            "type": "float",
                                            "example": 0.07,
                                            "description": "核黄素"
                                        },
                                        "xi": {
                                            "type": "float",
                                            "example": 8.6,
                                            "description": "硒"
                                        },
                                        "ys": {
                                            "type": "float",
                                            "example": 0.7,
                                            "description": "烟酸"
                                        },
                                        "zf": {
                                            "type": "float",
                                            "example": 17.6,
                                            "description": "脂肪"
                                        },
                                        "dbz": {
                                            "type": "float",
                                            "example": 6.9,
                                            "description": "蛋白质"
                                        },
                                        "dgc": {
                                            "type": "float",
                                            "example": 0,
                                            "description": "胆固醇"
                                        },
                                        "gai": {
                                            "type": "float",
                                            "example": 6,
                                            "description": "钙(毫克)"
                                        },
                                        "jia": {
                                            "type": "float",
                                            "example": 227,
                                            "description": "钾"
                                        },
                                        "las": {
                                            "type": "float",
                                            "example": 0.01,
                                            "description": "硫胺素"
                                        },
                                        "mei": {
                                            "type": "float",
                                            "example": 19,
                                            "description": "镁"
                                        },
                                        "shc": {
                                            "type": "float",
                                            "example": 21.8,
                                            "description": "视黄醇当量"
                                        },
                                        "tei": {
                                            "type": "float",
                                            "example": 1,
                                            "description": "铁"
                                        },
                                        "xin": {
                                            "type": "float",
                                            "example": 0.75,
                                            "description": "锌"
                                        },
                                        "ling": {
                                            "type": "float",
                                            "example": 77,
                                            "description": "磷"
                                        },
                                        "meng": {
                                            "type": "float",
                                            "example": 0.52,
                                            "description": "锰"
                                        },
                                        "name": {
                                            "type": "string",
                                            "example": "油条",
                                            "description": "食品名称"
                                        },
                                        "shhf": {
                                            "type": "float",
                                            "example": 50.1,
                                            "description": "碳水化合物"
                                        },
                                        "ssxw": {
                                            "type": "float",
                                            "example": 0.9,
                                            "description": "膳食纤维"
                                        },
                                        "tong": {
                                            "type": "float",
                                            "example": 0.19,
                                            "description": "铜"
                                        },
                                        "type": {
                                            "type": "string",
                                            "example": "谷类",
                                            "description": "食品种类"
                                        },
                                        "wsfc": {
                                            "type": "float",
                                            "example": 0,
                                            "description": "维生素C"
                                        },
                                        "wssa": {
                                            "type": "float",
                                            "example": 0,
                                            "description": "维生素A"
                                        },
                                        "wsse": {
                                            "type": "float",
                                            "example": 3.19,
                                            "description": "维生素E"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "la": 585.2,
                                        "lb": 2.7,
                                        "rl": 386,
                                        "su": 0.07,
                                        "xi": 8.6,
                                        "ys": 0.7,
                                        "zf": 17.6,
                                        "dbz": 6.9,
                                        "dgc": 0,
                                        "gai": 6,
                                        "jia": 227,
                                        "las": 0.01,
                                        "mei": 19,
                                        "shc": 21.8,
                                        "tei": 1,
                                        "xin": 0.75,
                                        "ling": 77,
                                        "meng": 0.52,
                                        "name": "油条",
                                        "shhf": 50.1,
                                        "ssxw": 0.9,
                                        "tong": 0.19,
                                        "type": "谷类",
                                        "wsfc": 0,
                                        "wssa": 0,
                                        "wsse": 3.19
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/nutrient\/ellist": {
            "get": {
                "summary": "查询元素列表",
                "tags": [
                    "营养成分表"
                ],
                "description": "查询营养元素的种类列表",
                "parameters": [
                    {
                        "name": "key",
                        "in": "query",
                        "description": "API密钥",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "description": "API密钥"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "el": {
                                            "type": "string",
                                            "example": "xin",
                                            "description": "营养元素"
                                        },
                                        "name": {
                                            "type": "string",
                                            "example": "锌",
                                            "description": "元素名称"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "list": [
                                            {
                                                "el": "rl",
                                                "name": "热量"
                                            },
                                            {
                                                "el": "zf",
                                                "name": "脂肪"
                                            },
                                            {
                                                "el": "dbz",
                                                "name": "蛋白质"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "查询元素列表",
                "tags": [
                    "营养成分表"
                ],
                "description": "查询营养元素的种类列表",
                "requestBody": {
                    "content": {
                        "application\/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "API密钥"
                                    }
                                },
                                "required": [
                                    "key"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "el": {
                                            "type": "string",
                                            "example": "xin",
                                            "description": "营养元素"
                                        },
                                        "name": {
                                            "type": "string",
                                            "example": "锌",
                                            "description": "元素名称"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "list": [
                                            {
                                                "el": "rl",
                                                "name": "热量"
                                            },
                                            {
                                                "el": "zf",
                                                "name": "脂肪"
                                            },
                                            {
                                                "el": "dbz",
                                                "name": "蛋白质"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}