Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions foodsnap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# FoodSnap AI - Simple Calorie Estimator CLI

---

## 🚀 Project Overview

**FoodSnap AI** is a lightweight Python command-line tool designed to estimate the caloric content and macronutrient breakdown (protein, carbs, fats) of a food item based on user input. It leverages a food nutrition API (such as Spoonacular) to provide accurate nutritional data quickly and easily — no manual lookup required!

---

## ✨ Features

- Accepts **food item name** as input via CLI.
- Retrieves **calories, protein, carbohydrates, and fat** estimates from an API.
- Minimalistic command-line interface — easy and fast to use.
- Built using Python and the popular `requests` library for HTTP requests.

---

## 🛠️ Tech Stack

- **Python 3.x**
- **requests** library
- **Spoonacular API** (or any equivalent food nutrition API)

---

## ⚙️ Setup & Installation

1. **Clone the repository** (if not already done):
bash
git clone https://github.com/YOUR_USERNAME/foodsnap-ai.git
cd foodsnap-ai


2. **Navigate to the `foodsnap` directory**:
bash
cd foodsnap

3. **Install dependencies**:
bash
pip install requests
4. **Create or edit your main Python script**:
- The main script file is `main.py`.
- Use any text editor or IDE of your choice.

## ▶️ How to Run

Run the following command in your terminal:

```bash
python main.py
19 changes: 19 additions & 0 deletions foodsnap/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import requests

def get_nutrition(food_name, api_key):
url = f"https://api.spoonacular.com/recipes/guessNutrition?title={food_name}&apiKey={api_key}"
response = requests.get(url)

if response.status_code == 200:
data = response.json()
print(f"Estimated Calories: {data['calories']['value']} kcal")
print(f"Fat: {data['fat']['value']} g")
print(f"Carbs: {data['carbs']['value']} g")
print(f"Protein: {data['protein']['value']} g")
else:
print("Error fetching data:", response.status_code, response.text)

if __name__ == "__main__":
food = input("Enter the food item: ")
api_key = "2c303386a88c42af8870115216f3c85c" # Replace with your Spoonacular API key
get_nutrition(food, api_key)