If you want to retrieve a list of items by their NDB
number (an id assigned by the USDA). Then you can send Nutritionix a filter to get all its sizes. "remote_db_id":3
tells us to filter by our USDA database and "remote_db_key":11143
tells us to filter by the NDB
number.
curl -XPOST https://api.nutritionix.com/v1_1/search -d'
{
"appId":"YOUR_APP_ID",
"appKey":"YOUR_APP_KEY",
"fields": [
"remote_db_id",
"remote_db_key",
"item_name",
"brand_name",
"item_id"
],
"filters": {
"remote_db_id": 3,
"remote_db_key": 11143
}
}'
If you do not have an NDB
number to filter by you can use a query
and a filter
to return only relavent USDA items. This will return items with their remote_db_id
and remote_db_key
from USDA so you can get an NDB
number to filter by.
curl -XPOST https://api.nutritionix.com/v1_1/search -d'
{
"appId":"YOUR_APP_ID",
"appKey":"YOUR_APP_KEY",
"fields": [
"remote_db_id",
"remote_db_key",
"item_name",
"brand_name",
"item_id"
],
"query":"celery",
"filters": {
"remote_db_id": 3
}
}'
{
"total": 6,
"max_score": 1,
"hits": [
{
"_index": "9fa412b9-1dbc-4e35-be7a-0c0c9c8c8e16",
"_type": "item",
"_id": "513fceb575b8dbbc210014fe",
"_score": 1,
"fields": {
"remote_db_id": 3,
"remote_db_key": 11143,
"item_name": "Celery, Raw - 1 stalk, medium (7-1/2\" - ",
"brand_name": "USDA",
"item_id": "513fceb575b8dbbc210014fe"
}
},
{
"_index": "9fa412b9-1dbc-4e35-be7a-0c0c9c8c8e16",
"_type": "item",
"_id": "513fceb575b8dbbc21001501",
"_score": 1,
"fields": {
"remote_db_id": 3,
"remote_db_key": 11143,
"item_name": "Celery, Raw - 1 NLEA serving",
"brand_name": "USDA",
"item_id": "513fceb575b8dbbc21001501"
}
},
{
"_index": "9fa412b9-1dbc-4e35-be7a-0c0c9c8c8e16",
"_type": "item",
"_id": "513fceb575b8dbbc210014fd",
"_score": 1,
"fields": {
"remote_db_id": 3,
"remote_db_key": 11143,
"item_name": "Celery, Raw - 1 stalk, small (5\" long)",
"brand_name": "USDA",
"item_id": "513fceb575b8dbbc210014fd"
}
},
{
"_index": "9fa412b9-1dbc-4e35-be7a-0c0c9c8c8e16",
"_type": "item",
"_id": "513fceb575b8dbbc21001500",
"_score": 1,
"fields": {
"remote_db_id": 3,
"remote_db_key": 11143,
"item_name": "Celery, Raw - 1 tbsp",
"brand_name": "USDA",
"item_id": "513fceb575b8dbbc21001500"
}
},
{
"_index": "9fa412b9-1dbc-4e35-be7a-0c0c9c8c8e16",
"_type": "item",
"_id": "513fceb575b8dbbc210014fc",
"_score": 1,
"fields": {
"remote_db_id": 3,
"remote_db_key": 11143,
"item_name": "Celery, Raw - 1 strip (4\" long)",
"brand_name": "USDA",
"item_id": "513fceb575b8dbbc210014fc"
}
},
{
"_index": "9fa412b9-1dbc-4e35-be7a-0c0c9c8c8e16",
"_type": "item",
"_id": "513fceb575b8dbbc210014ff",
"_score": 1,
"fields": {
"remote_db_id": 3,
"remote_db_key": 11143,
"item_name": "Celery, Raw - 1 stalk, large (11\"-12\" lo",
"brand_name": "USDA",
"item_id": "513fceb575b8dbbc210014ff"
}
}
]
}