Skip to content

fyipedia/nutrifyi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nutrifyi

PyPI version Python License: MIT Zero Dependencies

Python API client for nutrition data and food composition analysis. Query macronutrient and micronutrient profiles, look up USDA food composition data, calculate Recommended Dietary Allowances (RDA), and compare nutrient density across foods — all from NutriFYI, a nutrition reference platform with comprehensive food composition data.

Built on USDA FoodData Central and international food composition databases, NutriFYI provides structured access to calories, protein, fat, carbohydrates, vitamins, minerals, and dietary fiber for thousands of foods — used by nutrition app developers, dietitians, and health-tech platforms.

Explore nutrition data at nutrifyi.com — browse foods, compare nutrients, and calculate dietary intake.

nutrifyi demo — food nutrition lookup, macronutrient analysis, and dietary comparison in Python

Table of Contents

Install

pip install nutrifyi                # Core (zero deps)
pip install "nutrifyi[cli]"         # + Command-line interface
pip install "nutrifyi[mcp]"         # + MCP server for AI assistants
pip install "nutrifyi[api]"         # + HTTP client for nutrifyi.com API
pip install "nutrifyi[all]"         # Everything

Quick Start

from nutrifyi.api import NutriFYI

with NutriFYI() as api:
    # Get full nutrition profile for a food
    food = api.get_food("chicken-breast")
    print(food["calories"])          # 165 kcal per 100g
    print(food["protein"])           # 31.0g
    print(food["fat"])               # 3.6g

    # Search the food database
    results = api.search("quinoa")
    for r in results:
        print(f"{r['name']}: {r['calories']} kcal/100g")

    # List nutrient categories
    nutrients = api.list_nutrients()

What You Can Do

Macronutrient Profiles

The three macronutrients — protein, carbohydrates, and fat — provide the body's caloric energy. Each macronutrient serves distinct metabolic functions: protein for tissue building (4 kcal/g), carbohydrates for immediate energy (4 kcal/g), and fat for energy storage and hormone synthesis (9 kcal/g).

Macronutrient Energy RDA (Adult) Primary Function
Protein 4 kcal/g 0.8 g/kg body weight Tissue repair, enzymes, immune function
Carbohydrates 4 kcal/g 130 g/day Glucose for brain and muscles
Fat 9 kcal/g 20-35% of calories Cell membranes, hormones, fat-soluble vitamins
Fiber 0 kcal/g 25-38 g/day Gut health, cholesterol reduction
Water 0 kcal 2.7-3.7 L/day Every metabolic process
from nutrifyi.api import NutriFYI

with NutriFYI() as api:
    # Full macronutrient breakdown per 100g
    food = api.get_food("salmon-atlantic")
    print(f"Calories: {food['calories']} kcal")
    print(f"Protein: {food['protein']}g")
    print(f"Fat: {food['fat']}g (Saturated: {food['saturated_fat']}g)")
    print(f"Carbs: {food['carbohydrates']}g")
    print(f"Fiber: {food['fiber']}g")

Learn more: Food Database · Glossary

Micronutrients (Vitamins and Minerals)

Micronutrients are required in small amounts but are essential for enzyme function, bone health, immune response, and cellular repair. They divide into fat-soluble vitamins (A, D, E, K — stored in body fat), water-soluble vitamins (B-complex, C — excreted daily), and minerals (macro and trace).

Category Nutrients Key Functions
Fat-soluble vitamins A, D, E, K Vision, bone health, antioxidant, coagulation
Water-soluble vitamins B1-B12, C, Folate Energy metabolism, collagen, red blood cells
Macro-minerals Ca, P, Mg, Na, K Bone structure, nerve function, fluid balance
Trace minerals Fe, Zn, Cu, Se, I Oxygen transport, immune function, thyroid
from nutrifyi.api import NutriFYI

with NutriFYI() as api:
    # Get micronutrient data for a food
    food = api.get_food("spinach")
    vitamins = food["vitamins"]
    minerals = food["minerals"]
    print(f"Vitamin A: {vitamins['vitamin_a']} mcg RAE")
    print(f"Iron: {minerals['iron']} mg")
    print(f"Calcium: {minerals['calcium']} mg")

Learn more: Nutrients · Guides

Food Comparison

Comparing foods by nutrient density — nutrients per calorie rather than per weight — reveals which foods deliver the most nutritional value. Leafy greens and organ meats top nutrient density rankings, while refined grains and sugars score lowest.

from nutrifyi.api import NutriFYI

with NutriFYI() as api:
    # Compare two foods side by side
    comparison = api.compare("chicken-breast", "tofu")
    print(f"Protein: {comparison['food1']['protein']}g vs {comparison['food2']['protein']}g")
    print(f"Calories: {comparison['food1']['calories']} vs {comparison['food2']['calories']}")

Learn more: Food Comparison · Glossary

Dietary Reference Intakes

Dietary Reference Intakes (DRIs) established by the National Academies provide science-based nutrient intake recommendations. The system includes RDA (Recommended Dietary Allowance), AI (Adequate Intake), UL (Tolerable Upper Intake Level), and EAR (Estimated Average Requirement).

Term Definition Use
RDA Meets needs of 97-98% of population Daily target
AI Used when RDA cannot be determined Estimated target
UL Maximum safe daily intake Upper safety limit
EAR Meets needs of 50% of population Population assessment
from nutrifyi.api import NutriFYI

with NutriFYI() as api:
    # Look up nutrient RDA values
    nutrients = api.list_nutrients()
    for n in nutrients[:5]:
        print(f"{n['name']}: RDA {n['rda']} {n['unit']}")

Learn more: Dietary Guidelines · API Documentation

Command-Line Interface

pip install "nutrifyi[cli]"

nutrifyi food chicken-breast                # Full nutrition profile
nutrifyi search "brown rice"                # Search food database
nutrifyi compare chicken-breast tofu        # Side-by-side comparison
nutrifyi nutrients                          # List all tracked nutrients

MCP Server (Claude, Cursor, Windsurf)

pip install "nutrifyi[mcp]"
{
    "mcpServers": {
        "nutrifyi": {
            "command": "uvx",
            "args": ["--from", "nutrifyi[mcp]", "python", "-m", "nutrifyi.mcp_server"]
        }
    }
}

REST API Client

from nutrifyi.api import NutriFYI

with NutriFYI() as api:
    food = api.get_food("chicken-breast")        # GET /api/v1/foods/chicken-breast/
    nutrients = api.list_nutrients()              # GET /api/v1/nutrients/
    results = api.search("avocado")              # GET /api/v1/search/?q=avocado

Example

curl -s "https://nutrifyi.com/api/v1/foods/chicken-breast/"
{
    "slug": "chicken-breast",
    "name": "Chicken Breast (cooked)",
    "calories": 165,
    "protein": 31.0,
    "fat": 3.6,
    "carbohydrates": 0.0,
    "fiber": 0.0
}

Full API documentation at nutrifyi.com/developers/.

API Reference

Function Description
api.get_food(slug) Full nutrition profile (macros + micros)
api.list_foods() List all foods in database
api.search(query) Search food database
api.compare(food1, food2) Side-by-side nutrient comparison
api.list_nutrients() All tracked nutrients with RDA values
api.get_nutrient(slug) Nutrient details and top food sources

Learn More About Nutrition

Also Available

Platform Install Link
npm npm install nutrifyi npm
MCP uvx --from "nutrifyi[mcp]" python -m nutrifyi.mcp_server Config

Health FYI Family

Part of the FYIPedia open-source developer tools ecosystem — human body, medicine, and nutrition.

Package PyPI npm Description
anatomyfyi PyPI npm 14,692 anatomical structures, body systems, organs — anatomyfyi.com
pillfyi PyPI npm Pill identification, FDA drug database — pillfyi.com
drugfyi PyPI npm Drug interactions, pharmacology, side effects — drugfyi.com
nutrifyi PyPI npm Nutrition data, food composition, dietary analysis — nutrifyi.com

Embed Widget

Embed NutriFYI widgets on any website with nutrifyi-embed:

<script src="https://cdn.jsdelivr.net/npm/nutrifyi-embed@1/dist/embed.min.js"></script>
<div data-nutrifyi="entity" data-slug="example"></div>

Zero dependencies · Shadow DOM · 4 themes (light/dark/sepia/auto) · Widget docs

License

MIT

About

Nutrition data, food composition, dietary analysis — Python library & CLI. Zero dependencies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages