Python 使用美国农业部API

Python 使用美国农业部API,python,api,usda-fooddata-central-api,Python,Api,Usda Fooddata Central Api,美国农业部API链接供参考: 我目前正在用Python创建一个程序,该程序引用了美国农业部的搜索API。我试图通过将&ds=SR添加到下面的API链接中,将数据源参数设置为“Standard Reference”,但是这不起作用 我做错了什么?如何让API链接在结果中也显示不同食物的食物组 谢谢大家! 您将遇到以下错误: { "errors": { "error": [ { "status": 400,

美国农业部API链接供参考:

我目前正在用Python创建一个程序,该程序引用了美国农业部的搜索API。我试图通过将&ds=SR添加到下面的API链接中,将数据源参数设置为“Standard Reference”,但是这不起作用

我做错了什么?如何让API链接在结果中也显示不同食物的食物组


谢谢大家!

您将遇到以下错误:

{
    "errors": {
        "error": [
            {
                "status": 400,
                "parameter": "ds",
                "message": "Unknown ds (Data Source) -- can be Branded Food Products or Standard Reference."
            }
        ]
    }
}
它提示
ds
参数应为
品牌食品
标准参考
,因此请使用重试。。。瞧

{
    "list": {
        "q": "butter",
        "sr": "1",
        "ds": "Standard Reference",
        "start": 0,
        "end": 25,
        "total": 104,
        "group": "",
        "sort": "n",
        "item": [
            {
                "offset": 0,
                "group": "Baked Products",
                "name": "Archway Home Style Cookies, Peanut Butter",
                "ndbno": "18541",
                "ds": "SR",
                "manu": "Archway Cookies"
            },
            {
                "offset": 1,
                "group": "Dairy and Egg Products",
                "name": "Butter, Clarified butter (ghee)",
                "ndbno": "01323",
                "ds": "SR",
                "manu": "none"
            },
            ...