# Food Product Scraper — Nutrition, Ingredients & Barcodes (`hichemdev/openfoodfacts-scraper`) Actor

Scrape food and grocery products: brand, category, barcode, ingredients, allergens, full nutrition per 100g, Nutri-Score, NOVA group and Eco-Score. Search by keyword, category, brand or barcode.

- **URL**: https://apify.com/hichemdev/openfoodfacts-scraper.md
- **Developed by:** [Hichem Ben Moussa](https://apify.com/hichemdev) (community)
- **Categories:** E-commerce, Business, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 products

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Food Product Scraper — Nutrition, Ingredients & Barcodes

Scrape **food and grocery products** — **brand, category, barcode, ingredients, allergens, full nutrition per 100g, Nutri-Score, NOVA group and Eco-Score**. Search by keyword, category, brand or look up exact barcodes. No API key.

### What you can do with it

- 🥗 **Nutrition & diet apps** — populate a product database with real nutrition facts
- 🏷️ **CPG competitor research** — compare formulations and scores across brands
- 🛒 **Retail & category analytics** — sugar, salt or protein distribution in a category
- ⚠️ **Allergen screening** — filter products by allergen tags
- 📦 **Barcode enrichment** — turn EAN/UPC codes into full product records

### Input

| Field | Type | Description |
|-------|------|-------------|
| `searchTerm` | string | Free-text search, e.g. `protein bar`, `oat milk`. |
| `category` | string | Category in English, e.g. `Breakfast cereals`, `Snacks`. |
| `brand` | string | Brand name, e.g. `Nestle`. |
| `country` | string | Country sold in, e.g. `United States`. |
| `nutritionGrade` | select | Filter by Nutri-Score A–E. |
| `barcodes` | array | Look up exact EAN/UPC codes (overrides search). |
| `maxProducts` | integer | Max products to scrape. |

#### Example

```json
{ "searchTerm": "protein bar", "maxProducts": 200 }
```

### Output

```json
{
  "barcode": "3017620422003",
  "name": "Nutella",
  "brands": "Nutella, Ferrero",
  "categories": "Spreads, Sweet spreads",
  "ingredients": "Sugar, palm oil, hazelnuts 13%, skimmed milk powder...",
  "allergens": ["milk", "nuts", "soybeans"],
  "nutriScore": "E",
  "novaGroup": 4,
  "energyKcal100g": 539,
  "sugars100g": 56.3,
  "fat100g": 30.9,
  "proteins100g": 6.3,
  "salt100g": 0.107,
  "image": "https://images.openfoodfacts.org/....jpg",
  "url": "https://world.openfoodfacts.org/product/3017620422003"
}
```

Export to JSON, CSV, Excel, or pull live via the Apify API.

### Notes

- Data comes from **Open Food Facts**, a community-maintained open database of ~3M products.
- Because it's crowd-sourced, **coverage varies** — some products have partial nutrition data. Records without a product name are skipped.
- Their service occasionally returns `503` under load; the Actor backs off and retries automatically.

# Actor input Schema

## `searchTerm` (type: `string`):

Free-text product search, e.g. "protein bar", "oat milk", "greek yogurt".

## `category` (type: `string`):

Category name in English, e.g. "Breakfast cereals", "Snacks", "Beverages", "Yogurts".

## `brand` (type: `string`):

Brand name, e.g. "Nestle", "Kelloggs", "Danone".

## `country` (type: `string`):

Country the product is sold in, e.g. "United States", "France", "United Kingdom".

## `nutritionGrade` (type: `string`):

Filter by Nutri-Score grade.

## `barcodes` (type: `array`):

Look up specific product barcodes (EAN/UPC). Overrides the search filters.

## `maxProducts` (type: `integer`):

Maximum number of products to scrape.

## `proxyConfiguration` (type: `object`):

Optional. The Open Food Facts API is public and works without a proxy.

## Actor input object example

```json
{
  "searchTerm": "protein bar",
  "nutritionGrade": "",
  "barcodes": [],
  "maxProducts": 25,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

All scraped items as JSON.

## `overview` (type: `string`):

Browse results in the Apify Console.

# 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 = {
    "searchTerm": "protein bar",
    "category": "",
    "brand": "",
    "country": "",
    "barcodes": [],
    "maxProducts": 25
};

// Run the Actor and wait for it to finish
const run = await client.actor("hichemdev/openfoodfacts-scraper").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 = {
    "searchTerm": "protein bar",
    "category": "",
    "brand": "",
    "country": "",
    "barcodes": [],
    "maxProducts": 25,
}

# Run the Actor and wait for it to finish
run = client.actor("hichemdev/openfoodfacts-scraper").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 '{
  "searchTerm": "protein bar",
  "category": "",
  "brand": "",
  "country": "",
  "barcodes": [],
  "maxProducts": 25
}' |
apify call hichemdev/openfoodfacts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hichemdev/openfoodfacts-scraper"
        }
    }
}
```

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/u393qS6MO8cqGFQSa/builds/m9byLTCnekeTykVTl/openapi.json
