Reputation: 1
USDA API Link for Reference: https://ndb.nal.usda.gov/ndb/doc/apilist/API-SEARCH.md
I'm currently creating a program in Python that references the USDA Search API. I tried to set the data source parameter to "Standard Reference" by adding &ds=SR into an API link such as the one below, however this did not work.
What am I doing wrong? How do I get the API link to display the food groups of different foods in the results as well too?
Thank you!
Upvotes: 0
Views: 906
Reputation: 169338
You're getting this error:
{
"errors": {
"error": [
{
"status": 400,
"parameter": "ds",
"message": "Unknown ds (Data Source) -- can be Branded Food Products or Standard Reference."
}
]
}
}
It hints that the ds
parameter should be Branded Food Products
or Standard Reference
, so trying again with https://api.nal.usda.gov/ndb/search/?format=json&q=butter&sort=n&max=25&offset=0&api_key=DEMO_KEY&ds=Standard%20Reference ... voilà!
{
"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"
},
...
Upvotes: 1