API

When you use the site, you will see a url corresponding to the food being viewed.

http://eatnutrients.com/sr28/9037

sr28 indicates the USDA database version SR28.

9037, the last part of the url, is the id (used by USDA) for Avacodos.

Getting detailed data

You can get JSON data rather than the web page by using the same url, but including a 1 prefix (for the API version).

curl -H 'Accept: application/json' http://eatnutrients.com/1/sr28/9037

{
    "Tocopherol, beta": 0.05,
    "Vitamin E": 2.07,
    "Caffeine": 0,
    "Galactose": 0.1,
    "n-6": 0.015,
    "Water": 73.23,
    "Iron, Fe": 0.55,
    "16:0": 2.075,
    "Beta-sitosterol": 76,
    "17:1": 0.01,
    "id": 9037,
    "Maltose": 0,
    "foodGroup": "Fruits and Fruit Juices",
    "Leucine": 0.143,
    "Carotene, alpha": 24,
    "18:1 undifferentiated": 9.066,
    "Tyrosine": 0.049,
    "Fatty acids, total monounsaturated": 9.799,
    "Copper, Cu": 0.19,
    "Vitamin A, IU": 146,
    "Arginine": 0.088,
    "Cryptoxanthin, beta": 28,
    "Histidine": 0.049,
    "12:0": 0,
    "Campesterol": 5,
    "20:1": 0.025,
    "Vitamin E, added": 0,
    "Vitamin B-6": 0.257,
    "caloric": true,
    "Fatty acids, total saturated": 2.126,
    "Valine": 0.107,
    "Lycopene": 0,
    "18:4": 0,
    "Retinol": 0,
    "Fructose": 0.12,
    "20:4 undifferentiated": 0,
    "Vitamin D (D2 + D3)": 0,
    "16:1 undifferentiated": 0.698,
    "14:0": 0,
    "15:1": 0,
    "Sugars, total": 0.66,
    "Tocopherol, delta": 0.02,
    "Starch": 0.11,
    "Cystine": 0.027,
    "Vitamin K (phylloquinone)": 21,
    "Vitamin C": 10,
    "Tryptophan": 0.025,
    "Glucose (dextrose)": 0.37,
    "18:3 undifferentiated": 0.125,
    "Lactose": 0,
    "Proline": 0.098,
    "Glutamic acid": 0.287,
    "18:0": 0.049,
    "weights": [
        {
            "desc": "avocado, NS as to Florida or California",
            "amount": 1,
            "grams": 201
        },
        {
            "desc": "cup, sliced",
            "amount": 1,
            "grams": 146
        },
        {
            "desc": "cup, pureed",
            "amount": 1,
            "grams": 230
        },
        {
            "desc": "cup, cubes",
            "amount": 1,
            "grams": 150
        }
    ],
    "20:2 n-6 c,c": 0,
    "Glycine": 0.104,
    "22:5 n-3 (DPA)": 0,
    "Vitamin K": 21,
    "10:0": 0,
    "Phosphorus, P": 52,
    "Vitamin A, RAE": 7,
    "Carotene, beta": 62,
    "longDesc": "Avocados, raw, all commercial varieties",
    "Folate, food": 81,
    "Protein": 2,
    "Folate, total": 81,
    "Lysine": 0.132,
    "Vitamin D": 0,
    "Magnesium, Mg": 29,
    "manufacName": "",
    "Vitamin B-12": 0,
    "24:0": 0,
    "17:0": 0,
    "Dihydrophylloquinone": 0,
    "Riboflavin": 0.13,
    "Potassium, K": 485,
    "langual": "VEGETABLE OR VEGETABLE PRODUCT. AVOCADO. FRUIT, PEEL REMOVED, CORE, PIT OR SEED REMOVED. WHOLE, NATURAL SHAPE. NOT HEAT-TREATED. COOKING METHOD NOT APPLICABLE. NO TREATMENT APPLIED. PRESERVATION METHOD NOT KNOWN. NO PACKING MEDIUM USED. CONTAINER OR WRAPPING NOT KNOWN. FOOD CONTACT SURFACE NOT KNOWN. HUMAN FOOD, NO AGE SPECIFICATION",
    "6:0": 0,
    "Aspartic acid": 0.236,
    "Alanine": 0.109,
    "Fluoride, F": 7,
    "Vitamin B-12, added": 0,
    "Folic acid": 0,
    "Betaine": 0.7,
    "Tocopherol, gamma": 0.33,
    "n-3": 0.111,
    "22:6 n-3 (DHA)": 0,
    "20:0": 0,
    "Total lipid (fat)": 14.66,
    "Threonine": 0.073,
    "20:5 n-3 (EPA)": 0,
    "20:3 undifferentiated": 0.016,
    "22:1 undifferentiated": 0,
    "Isoleucine": 0.084,
    "Fatty acids, total polyunsaturated": 1.816,
    "realFood": true,
    "Theobromine": 0,
    "comName": "",
    "Phenylalanine": 0.097,
    "Zinc, Zn": 0.64,
    "Serine": 0.114,
    "Lutein + zeaxanthin": 271,
    "18:3 n-6 c,c,c": 0.015,
    "Manganese, Mn": 0.142,
    "Stigmasterol": 2,
    "Pantothenic acid": 1.389,
    "15:0": 0,
    "14:1": 0,
    "Sucrose": 0.06,
    "Cholesterol": 0,
    "sciName": "Persea americana",
    "Thiamin": 0.067,
    "Methionine": 0.038,
    "18:3 n-3 c,c,c (ALA)": 0.111,
    "Folate, DFE": 81,
    "4:0": 0,
    "18:2 undifferentiated": 1.674,
    "Niacin": 1.738,
    "Fiber, total dietary": 6.7,
    "Energy": 160,
    "Calcium, Ca": 12,
    "8:0": 0.001,
    "Choline": 14.2,
    "22:0": 0,
    "Sodium, Na": 7,
    "Carbohydrate, by difference": 8.53,
    "Alcohol, ethyl": 0,
    "Ash": 1.58,
    "Selenium, Se": 0.4
}

Searching for food

You can also use the search tool to find foods. Here we will use the chome console and jQuery.

> xhr = $.getJSON('http://eatnutrients.com/1/search', {search:'avo'})
> result = JSON.parse(xhr.response)['result']
> result[0]['longDesc']
"Avocados, raw, all commercial varieties"
> result[0]['id']
9037

The search returns the ‘Energy’ data of the foods found, which may be all the data you want. If you want the complete details of the nutrition data for a food, use the id to look it up as per the detailed data example.

If the seach doesn’t turn anything up, it will try to suggest an alternative:

> xhr = $.getJSON('http://eatnutrients.com/1/search', {search:'banano'})
> JSON.stringify(JSON.parse(xhr.response),null,4)
  "{
      "suggest": [
          "banana",
          "bananas"
      ]
  }"