Nutrition API

Description

Lookup nutritional values for tens of thousands of food products. Our dataset is curated from a variety of sources including FDC/USDA.

Bulk Data Download:

If you need a complete data dump of our entire Nutrition database, reach out to us. We offer that as a separate service option. Trying to scrape our APIs is not recommended as you'll end up consuming your monthly request allowance.

Dataset Expansion:

If requested by our users, we can expand this endpoint to include hundreds of thousands of branded items that are sold at grocery stores. Let us know if such an expansion is something you'd like to see and we'll make it happen!

Endpoint

> GET https://api.jsonrepo.com/v1/knowledge/food/nutrition

Headers

Field Description
api_key Required Your API Key

Parameters

Field Type Description
item String Required The name of the product (case insensitive)
Example: eggs
limit Integer Optional Number of results
Default: 10
Range: 1 <= limit <= 20

Search Strictness Policy:

This endpoint will use non-strict search. The item parameter provided will be searched against all possible matches including partial ones.

Response

A successful request will result in a populated payload field with the expected output.

Response Size:

Please note that this endpoint returns a lot of data. The payload data will usually contain dozens and dozens of data points for every match. When printed as beautiful JSON, which is how our responses are usually sent, a single match could easily include 500+ lines of nutritional data.

A failed request will result in an error output as detailed in Error Rules. If the endpoint validation fails due to missing, badly formatted or invalid parameters, the endpoint will return HTTP code 400 along with a message detailing the error.

See the examples section for more information.

Request

  • Curl
// Look up the first entry that match `hummus`

curl -G \
https://api.jsonrepo.com/v1/knowledge/food/nutrition \
-H "api_key: {YOUR_API_KEY_HERE}" \
--data-urlencode "item=hummus" \
--data-urlencode "limit=1" 

Success Response

{
    "http_code": 200,
    "http_message": "Ok",
    "message": "Successful execution",
    "payload": {
        "entries": [
            {
                "id": 4943,
                "fdc_id": "172454",
                "item": "Hummus, home prepared",
                "category": "Legumes and Legume Products",
                "ndb_number": "16137",
                "values_per_100g": [
                    {
                        "name": "Water",
                        "unit": "g",
                        "average": "64.9"
                    },
                    {
                        "name": "Total lipid (fat)",
                        "unit": "g",
                        "average": "8.59"
                    },
                    {
                        "name": "Zinc, Zn",
                        "unit": "mg",
                        "average": "1.09"
                    },
                    {
                        "name": "Selenium, Se",
                        "unit": "µg",
                        "average": "2.4"
                    },
                    {
                        "name": "Tocopherol, beta",
                        "unit": "mg",
                        "average": "0.01"
                    },
                    {
                        "name": "Vitamin B-6",
                        "unit": "mg",
                        "average": "0.399"
                    },
                    {
                        "name": "Protein",
                        "unit": "g",
                        "average": "4.86"
                    },
                    {
                        "name": "Sodium, Na",
                        "unit": "mg",
                        "average": "242"
                    },
                    {
                        "name": "Iron, Fe",
                        "unit": "mg",
                        "average": "1.56"
                    },
                    {
                        "name": "Magnesium, Mg",
                        "unit": "mg",
                        "average": "29"
                    },
                    {
                        "name": "Energy",
                        "unit": "kJ",
                        "average": "742"
                    },
                    {
                        "name": "Choline, total",
                        "unit": "mg",
                        "average": "27.8"
                    },
                    {
                        "name": "Vitamin E (alpha-tocopherol)",
                        "unit": "mg",
                        "average": "0.75"
                    },

                    // dozens and dozens of more data points below
                    ...
                ],
                "db_entry_last_updated_at": "2024-07-23 23:53:00"
            }
        ]
    }
}

Error Response Examples

// Request with missing `item` parameter

{
    "http_code": 400,
    "http_message": "Bad Request",
    "message": "Malformed request: `item` parameter was not provided.",
    "payload": []
}