Food Search
The foodSearch
is a powerful search query that allows users to search for food that can be logged such as recipes, USDA, branded food, products with barcodes, restaurants, etc. that matches the desired search criteria.
The FoodSearch
query allows users to nest their search queries. Results are the same as the queries will be used separately. The advantage is that all the information is gathered in one response.
To use the FoodSearch
query, place the query before the query name
query FoodSearch {
search queries
}
The following searched can be nested within the foodSearch
, these can be combined or used separately.
Characteristics
Use one, two, or more query searches within the
FoodSearch
queryAllow users to select the data type to be searched. For instance, a user wants to search for recipes, common, branded, and packaged foods at the same time.
Use filters to introduce nutrient ranges for macros and macronutrients.
Retrieve which group each food belongs to.
Define query variables to be sent as arguments in the
FoodSearch
queryAllow users to search for products introducing a specific barcode
How to use query variables
Use the QUERY VARIABLES tab to add variables, pass them as a parameter to the GraphQL query, and use them to fetch data.
Structure
In the FoodSearch
query, define the variables which are sent as arguments, then, define the query variables in the TAB which is located at the bottom left side of the navigator.
Within the QUERY VARIABLES tab, write the variables in a JSON format, and then execute the query.
Example
Common and Branded foods
The following example searches common and branded foods criteria by adding the commonFoods
and brandedFoods
within the FoodSearch
query.
query FoodSearch {
commonFoods: commonFoods(query: "cookie", first: 2) {
edges {
node {
id
name
description
portions {
amount
modifier
gramWeight
}
nutrients {
id
amount
name
unit
}
}
}
}
brandedFoods: brandedFoods(query: "oreo", first: 2) {
edges {
node {
id
name
gtinUpc
brandOwner
servingSize
servingSizeUnit
nutrients {
id
amount
name
unit
}
}
}
}
}
{
"data": {
"commonFoods": {
"edges": [
{
"node": {
"id": "Q29tbW9uRm9vZE5vZGU6MTcxMzY4",
"name": "Fruit baby cookie babyfood",
"description": "Babyfood, cookie, baby, fruit",
"portions": [
{
"amount": 1,
"modifier": "cookie",
"gramWeight": 8
}
],
"nutrients": [
{
"id": 1114,
"amount": 0,
"name": "Vitamin D (D2 + D3)",
"unit": "UG"
},
{
"id": 1110,
"amount": 0,
"name": "Vitamin D (D2 + D3), International Units",
"unit": "IU"
},
{
"id": 1123,
"amount": 175,
"name": "Lutein + zeaxanthin",
"unit": "UG"
},
{
"id": 1109,
"amount": 1.48,
"name": "Vitamin E (alpha-tocopherol)",
"unit": "MG"
},
{
"id": 1057,
"amount": 0,
"name": "Caffeine",
"unit": "MG"
},
{
"id": 1265,
"amount": 1.738,
"name": "16:0",
"unit": "G"
},
{
"id": 1266,
"amount": 0.84,
"name": "18:0",
"unit": "G"
},
{
"id": 1275,
"amount": 0.051,
"name": "16:1",
"unit": "G"
},
{
"id": 1278,
"amount": 0,
"name": "20:5 n-3 (EPA)",
"unit": "G"
},
{
"id": 1280,
"amount": 0,
"name": "22:5 n-3 (DPA)",
"unit": "G"
},
{
"id": 1093,
"amount": 9,
"name": "Sodium, Na",
"unit": "MG"
},
{
"id": 1098,
"amount": 0.04,
"name": "Copper, Cu",
"unit": "MG"
},
{
"id": 1101,
"amount": 0.22,
"name": "Manganese, Mn",
"unit": "MG"
},
{
"id": 1079,
"amount": 3.4,
"name": "Fiber, total dietary",
"unit": "G"
},
{
"id": 1089,
"amount": 2.9,
"name": "Iron, Fe",
"unit": "MG"
},
{
"id": 1090,
"amount": 30,
"name": "Magnesium, Mg",
"unit": "MG"
},
{
"id": 1091,
"amount": 189,
"name": "Phosphorus, P",
"unit": "MG"
},
{
"id": 1003,
"amount": 6.8,
"name": "Protein",
"unit": "G"
},
{
"id": 1007,
"amount": 1.2,
"name": "Ash",
"unit": "G"
},
{
"id": 1018,
"amount": 0,
"name": "Alcohol, ethyl",
"unit": "G"
}
]
}
},
{
"node": {
"id": "Q29tbW9uRm9vZE5vZGU6MTcyMjI3",
"name": "Ice cream cookie sandwich",
"description": "Ice cream cookie sandwich",
"portions": [
{
"amount": 1,
"modifier": "serving",
"gramWeight": 82
}
],
"nutrients": [
{
"id": 1003,
"amount": 3.7,
"name": "Protein",
"unit": "G"
},
{
"id": 1007,
"amount": 0.55,
"name": "Ash",
"unit": "G"
},
{
"id": 1018,
"amount": 0,
"name": "Alcohol, ethyl",
"unit": "G"
},
{
"id": 1062,
"amount": 1003,
"name": "Energy",
"unit": "kJ"
},
{
"id": 1079,
"amount": 1.2,
"name": "Fiber, total dietary",
"unit": "G"
},
{
"id": 1089,
"amount": 1.1,
"name": "Iron, Fe",
"unit": "MG"
},
{
"id": 1090,
"amount": 16,
"name": "Magnesium, Mg",
"unit": "MG"
},
{
"id": 1091,
"amount": 54,
"name": "Phosphorus, P",
"unit": "MG"
},
{
"id": 1093,
"amount": 162,
"name": "Sodium, Na",
"unit": "MG"
},
{
"id": 1098,
"amount": 0.106,
"name": "Copper, Cu",
"unit": "MG"
},
{
"id": 1101,
"amount": 0.225,
"name": "Manganese, Mn",
"unit": "MG"
},
{
"id": 1104,
"amount": 122,
"name": "Vitamin A, IU",
"unit": "IU"
},
{
"id": 1178,
"amount": 0.01,
"name": "Vitamin B-12",
"unit": "UG"
},
{
"id": 1185,
"amount": 1.3,
"name": "Vitamin K (phylloquinone)",
"unit": "UG"
},
{
"id": 1187,
"amount": 5,
"name": "Folate, food",
"unit": "UG"
},
{
"id": 1246,
"amount": 0,
"name": "Vitamin B-12, added",
"unit": "UG"
},
{
"id": 1253,
"amount": 6,
"name": "Cholesterol",
"unit": "MG"
},
{
"id": 1258,
"amount": 1.663,
"name": "Fatty acids, total saturated",
"unit": "G"
},
{
"id": 1261,
"amount": 0.05,
"name": "8:0",
"unit": "G"
},
{
"id": 1263,
"amount": 0.004,
"name": "12:0",
"unit": "G"
},
{
"id": 1264,
"amount": 0.04,
"name": "14:0",
"unit": "G"
},
{
"id": 1272,
"amount": 0.001,
"name": "22:6 n-3 (DHA)",
"unit": "G"
},
{
"id": 1275,
"amount": 0.006,
"name": "16:1",
"unit": "G"
},
{
"id": 1278,
"amount": 0.001,
"name": "20:5 n-3 (EPA)",
"unit": "G"
},
{
"id": 1280,
"amount": 0,
"name": "22:5 n-3 (DPA)",
"unit": "G"
},
{
"id": 1004,
"amount": 7.4,
"name": "Total lipid (fat)",
"unit": "G"
},
{
"id": 1005,
"amount": 39.6,
"name": "Carbohydrate, by difference",
"unit": "G"
},
{
"id": 1008,
"amount": 240,
"name": "Energy",
"unit": "KCAL"
},
{
"id": 1051,
"amount": 48.7,
"name": "Water",
"unit": "G"
},
{
"id": 1057,
"amount": 6,
"name": "Caffeine",
"unit": "MG"
},
{
"id": 1058,
"amount": 42,
"name": "Theobromine",
"unit": "MG"
},
{
"id": 2000,
"amount": 21.3,
"name": "Sugars, total including NLEA",
"unit": "G"
},
{
"id": 1087,
"amount": 73,
"name": "Calcium, Ca",
"unit": "MG"
},
{
"id": 1092,
"amount": 68,
"name": "Potassium, K",
"unit": "MG"
},
{
"id": 1095,
"amount": 0.32,
"name": "Zinc, Zn",
"unit": "MG"
},
{
"id": 1103,
"amount": 3.1,
"name": "Selenium, Se",
"unit": "UG"
},
{
"id": 1109,
"amount": 0.4,
"name": "Vitamin E (alpha-tocopherol)",
"unit": "MG"
},
{
"id": 1110,
"amount": 0,
"name": "Vitamin D (D2 + D3), International Units",
"unit": "IU"
},
{
"id": 1123,
"amount": 6,
"name": "Lutein + zeaxanthin",
"unit": "UG"
},
{
"id": 1167,
"amount": 0.237,
"name": "Niacin",
"unit": "MG"
},
{
"id": 1170,
"amount": 0.115,
"name": "Pantothenic acid",
"unit": "MG"
},
{
"id": 1175,
"amount": 0.028,
"name": "Vitamin B-6",
"unit": "MG"
},
{
"id": 1180,
"amount": 8,
"name": "Choline, total",
"unit": "MG"
},
{
"id": 1186,
"amount": 0,
"name": "Folic acid",
"unit": "UG"
},
{
"id": 1190,
"amount": 5,
"name": "Folate, DFE",
"unit": "UG"
},
{
"id": 1242,
"amount": 0,
"name": "Vitamin E, added",
"unit": "MG"
},
{
"id": 1259,
"amount": 0,
"name": "4:0",
"unit": "G"
},
{
"id": 1260,
"amount": 0.004,
"name": "6:0",
"unit": "G"
},
{
"id": 1262,
"amount": 0.04,
"name": "10:0",
"unit": "G"
},
{
"id": 1265,
"amount": 0.211,
"name": "16:0",
"unit": "G"
},
{
"id": 1266,
"amount": 1.314,
"name": "18:0",
"unit": "G"
},
{
"id": 1268,
"amount": 4.144,
"name": "18:1",
"unit": "G"
},
{
"id": 1269,
"amount": 0.798,
"name": "18:2",
"unit": "G"
},
{
"id": 1270,
"amount": 0.043,
"name": "18:3",
"unit": "G"
},
{
"id": 1271,
"amount": 0.002,
"name": "20:4",
"unit": "G"
},
{
"id": 1276,
"amount": 0,
"name": "18:4",
"unit": "G"
},
{
"id": 1277,
"amount": 0,
"name": "20:1",
"unit": "G"
},
{
"id": 1279,
"amount": 0,
"name": "22:1",
"unit": "G"
},
{
"id": 1292,
"amount": 4.15,
"name": "Fatty acids, total monounsaturated",
"unit": "G"
},
{
"id": 1293,
"amount": 0.847,
"name": "Fatty acids, total polyunsaturated",
"unit": "G"
}
]
}
}
]
},
"brandedFoods": {
"edges": [
{
"node": {
"id": "QnJhbmRlZEZvb2ROb2RlOjM1MDcyNw==",
"name": "Nabisco oreo cookies oreo 1x10.700 oz",
"gtinUpc": "00044000042554",
"brandOwner": "Mondelez Int. US (0074819091009)",
"servingSize": 29,
"servingSizeUnit": "g",
"nutrients": [
{
"id": 1162,
"amount": 0,
"name": "Vitamin C, total ascorbic acid",
"unit": "MG"
},
{
"id": 1004,
"amount": 20.69,
"name": "Total lipid (fat)",
"unit": "G"
},
{
"id": 1005,
"amount": 72.41,
"name": "Carbohydrate, by difference",
"unit": "G"
},
{
"id": 2000,
"amount": 44.83,
"name": "Sugars, total including NLEA",
"unit": "G"
},
{
"id": 1087,
"amount": 40,
"name": "Calcium, Ca",
"unit": "MG"
},
{
"id": 1089,
"amount": 3.48,
"name": "Iron, Fe",
"unit": "MG"
},
{
"id": 1092,
"amount": 138,
"name": "Potassium, K",
"unit": "MG"
},
{
"id": 1093,
"amount": 345,
"name": "Sodium, Na",
"unit": "MG"
},
{
"id": 1253,
"amount": 0,
"name": "Cholesterol",
"unit": "MG"
},
{
"id": 1257,
"amount": 0,
"name": "Fatty acids, total trans",
"unit": "G"
},
{
"id": 1258,
"amount": 6.9,
"name": "Fatty acids, total saturated",
"unit": "G"
},
{
"id": 1003,
"amount": 3.45,
"name": "Protein",
"unit": "G"
},
{
"id": 1079,
"amount": 3.4,
"name": "Fiber, total dietary",
"unit": "G"
}
]
}
},
{
"node": {
"id": "QnJhbmRlZEZvb2ROb2RlOjM1MTUwOA==",
"name": "Nabisco oreo cookies oreo 1x45.000 oz",
"gtinUpc": "00044000013103",
"brandOwner": "Mondelez Int. US (0074819091009)",
"servingSize": 42,
"servingSizeUnit": "g",
"nutrients": [
{
"id": 1162,
"amount": 0,
"name": "Vitamin C, total ascorbic acid",
"unit": "MG"
},
{
"id": 1003,
"amount": 4.76,
"name": "Protein",
"unit": "G"
},
{
"id": 1004,
"amount": 19.05,
"name": "Total lipid (fat)",
"unit": "G"
},
{
"id": 1005,
"amount": 71.43,
"name": "Carbohydrate, by difference",
"unit": "G"
},
{
"id": 2000,
"amount": 40.48,
"name": "Sugars, total including NLEA",
"unit": "G"
},
{
"id": 1087,
"amount": 44,
"name": "Calcium, Ca",
"unit": "MG"
},
{
"id": 1089,
"amount": 5.19,
"name": "Iron, Fe",
"unit": "MG"
},
{
"id": 1092,
"amount": 155,
"name": "Potassium, K",
"unit": "MG"
},
{
"id": 1093,
"amount": 405,
"name": "Sodium, Na",
"unit": "MG"
},
{
"id": 1253,
"amount": 0,
"name": "Cholesterol",
"unit": "MG"
},
{
"id": 1257,
"amount": 0,
"name": "Fatty acids, total trans",
"unit": "G"
},
{
"id": 1258,
"amount": 4.76,
"name": "Fatty acids, total saturated",
"unit": "G"
},
{
"id": 1079,
"amount": 2.4,
"name": "Fiber, total dietary",
"unit": "G"
}
]
}
}
]
}
}
}
Common Foods and Recipes
The following example searches common foods and recipes criteria within the FoodSearch
query.
query FoodSearch {
commonFoods: commonFoods(query: "bread", first: 2) {
edges {
node {
id
name
description
portions {
amount
modifier
gramWeight
}
nutrients {
id
amount
name
unit
}
}
}