# USDA Food Nutrition Scraper — Calories, Protein & Macros (`copious_atoll/usda-food-nutrition`) Actor

Extract USDA FoodData Central nutritional data. Search 300K+ foods for calories, protein, fat, carbs, vitamins, minerals. Branded and generic foods. Free USDA API, no proxy needed.

- **URL**: https://apify.com/copious\_atoll/usda-food-nutrition.md
- **Developed by:** [Grim R](https://apify.com/copious_atoll) (community)
- **Categories:** E-commerce
- **Stats:** 4 total users, 0 monthly users, 59.2% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## USDA Food Nutrition Scraper

Extract nutritional data from USDA FoodData Central, the United States Department of Agriculture's comprehensive food composition database. Search over 300,000 foods for calories, protein, fat, carbohydrates, vitamins, minerals, and ingredients. Covers branded packaged foods, standard reference items, and foundation foods. Powered by the free USDA API — no proxy needed.

> **Disclaimer:** This actor is unofficial and is not affiliated with, sponsored by, or endorsed by the United States Department of Agriculture (USDA).

### What nutrition data can you extract?

This actor wraps the free USDA FoodData Central API to extract detailed nutritional information:

- **Macronutrients** — calories, protein, total fat, carbohydrates, fiber, sugar
- **Micronutrients** — sodium, cholesterol, calcium, iron, potassium, vitamins A and C
- **Fat breakdown** — saturated fat, trans fat
- **Food details** — brand owner, brand name, ingredients list, serving size, food category
- **Data types** — Branded (packaged foods), SR Legacy (standard reference), Foundation (enhanced profiles), Survey (FNDDS)

### Input parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| Food Search Term | string | Food to search for (e.g., "chicken breast", "greek yogurt") |
| Data Type | select | ALL, Branded, SR Legacy, Foundation, or Survey (FNDDS) |
| Max Results | integer | Maximum food items to return (1–1,000, default 50) |
| API Key | string | Free key from api.data.gov or DEMO\_KEY (rate limited) |

### Output example

Each food record contains:

```json
{
    "fdcId": 2038064,
    "description": "CHICKEN BREAST",
    "dataType": "Branded",
    "brandOwner": "Tyson Foods Inc.",
    "brandName": "TYSON",
    "ingredients": "BONELESS SKINLESS CHICKEN BREAST",
    "servingSize": 112.0,
    "servingSizeUnit": "g",
    "foodCategory": "Poultry",
    "calories": 110,
    "caloriesUnit": "KCAL",
    "protein": 23.0,
    "proteinUnit": "G",
    "totalFat": 2.5,
    "totalFatUnit": "G",
    "carbohydrates": 0.0,
    "carbohydratesUnit": "G",
    "fiber": 0.0,
    "fiberUnit": "G",
    "sodium": 210,
    "sodiumUnit": "MG",
    "source": "USDA FoodData Central",
    "sourceUrl": "https://fdc.nal.usda.gov/food-details/2038064/nutrients"
}
```

### How much does it cost to scrape USDA nutrition data?

This actor uses **pay-per-event pricing**. You pay per food item returned.

- **$0.00005 per actor start** (Apify default)
- **Per-result charge** based on the number of food items extracted
- **No proxy costs** — the USDA API is free and public

A typical search returns 50 food items at minimal cost. The DEMO\_KEY allows 30 requests per hour which is sufficient for most searches.

**Tip:** Use specific search terms and data type filters to get the most relevant results. Register for a free API key at api.data.gov for higher rate limits.

### Who uses USDA nutrition data?

- **Fitness app developers** — build calorie counters, macro trackers, and meal logging features
- **Nutritionists and dietitians** — research food composition for client meal plans
- **Meal planning services** — calculate nutritional totals for recipes and weekly meal plans
- **Food manufacturers** — compare nutritional profiles across product categories and competitors
- **Health researchers** — study dietary patterns, nutrient intake, and food composition trends
- **Recipe platforms** — auto-calculate nutrition facts for user-submitted recipes

### Tips for best results

- **Be specific** with search terms — "boneless skinless chicken breast" returns more relevant results than just "chicken."
- **Data types**: Branded = commercial packaged products with brand names. SR Legacy = USDA standard reference (generic foods). Foundation = enhanced nutrient data with detailed analytical methods.
- **DEMO\_KEY** allows 30 requests/hour, 50/day. For production use, get a free key from https://api.data.gov/signup/ — it takes 30 seconds and gives 1,000 requests/hour.
- **Serving sizes** vary by product. Normalize to 100g for cross-product comparisons.
- **Nutrient values** are per serving size as labeled by the manufacturer (Branded) or per 100g (SR Legacy/Foundation).

### Integrations

Export your data as JSON, CSV, or Excel. Schedule runs to track product reformulations or new items. Use webhooks to update your nutrition database when new data is available.

This actor works as an **MCP server** — AI agents can discover and use it to access USDA nutrition data programmatically.

# Actor input Schema

## `query` (type: `string`):

Search for a food item (e.g., 'chicken breast', 'greek yogurt', 'brown rice').

## `dataType` (type: `string`):

Filter by food data source. Branded = packaged foods with brand names. SR Legacy = USDA standard reference. Foundation = enhanced nutrient profiles.

## `maxResults` (type: `integer`):

Maximum number of food items to return.

## `apiKey` (type: `string`):

Free API key from api.data.gov (recommended) or use DEMO\_KEY (rate limited to 30 requests/hour).

## Actor input object example

```json
{
  "query": "chicken breast",
  "dataType": "ALL",
  "maxResults": 50,
  "apiKey": "DEMO_KEY"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "chicken breast",
    "dataType": "ALL",
    "maxResults": 50,
    "apiKey": "DEMO_KEY"
};

// Run the Actor and wait for it to finish
const run = await client.actor("copious_atoll/usda-food-nutrition").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "query": "chicken breast",
    "dataType": "ALL",
    "maxResults": 50,
    "apiKey": "DEMO_KEY",
}

# Run the Actor and wait for it to finish
run = client.actor("copious_atoll/usda-food-nutrition").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "chicken breast",
  "dataType": "ALL",
  "maxResults": 50,
  "apiKey": "DEMO_KEY"
}' |
apify call copious_atoll/usda-food-nutrition --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,copious_atoll/usda-food-nutrition"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/lfzdGqarewvzaWcbc/builds/v6iyrDz9AoU3qfTXE/openapi.json
