Datasets:
File size: 15,842 Bytes
2d74014 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | ---
license: cc-by-nc-4.0
task_categories:
- tabular-classification
- text-classification
- feature-extraction
- image-to-text
language:
- en
tags:
- food
- beverage
- nutrition
- ingredients
- allergens
- barcode
- gtin
- upc
- grocery
- packaged-food
- machine-learning
- computer-vision
pretty_name: "The Food API: Packaged Food & Beverage Products Dataset (Sample)"
size_categories:
- n<1K
---
# The Food API: Packaged Food & Beverage Products Dataset
**Normalized packaged-food and beverage product data, keyed by barcode, for food-tech, nutrition apps and e-commerce.**
This repository is the free evaluation sample of **The Food API**: one record per product with the barcode, the full ingredient statement and its parsed tree, declared and precautionary allergens, the nutrition panel, package claims and warnings, and the product and label photos. Every field is normalized to one documented schema, so it drops into a recommendation engine, a barcode scanner app or a training set on day one instead of after weeks of cleaning.
**[Join the waitlist for launch pricing and the full catalogue](https://thefoodapi.io)**
---
## 📊 Dataset Overview (release 2026.09, as of 23 September 2026)
- **Records:** 993 products across 520 brands (587 foods, 406 beverages), sold in the US
- **Barcodes:** a checksum-validated 14-digit **GTIN** on every product (`gtin`), so any scanned UPC/EAN resolves directly
- **Ingredients:** the ingredient statement as printed on every product, parsed into a component and sub-ingredient tree on 96%
- **Nutrition panel:** nutrient rows on 548 products; allergen declaration or precaution on 247
- **Images:** 1,286 files: 986 main product images plus label photos (ingredient list, nutrition panel, back of pack) on 190 products, all named by content hash
- **Formats:** interchangeable **JSONL** and **CSV**, one product per line or row
---
## 💡 Data Capabilities
### 1. Ingredient & Allergen Intelligence
Each product is parsed into structured fields that read like the label, not like a scrape.
- **Ingredient tree:** `ingredients_parsed` keeps label order, groups by labelled component (`Filling`, `Crust`), nests the parenthesized sub-ingredients of compound ingredients, and carries the `Contains 2% or less of` threshold as `max_percent`.
- **Allergens as identities:** `allergens_declared` and `allergens_may_contain` use fixed identities (`milk`, `wheat`, `soy`, `peanut`, `tree_nut`, `sesame`, …) for filtering, with the exact package wording preserved in `allergens_statement`.
- **Sweeteners and claims:** non-nutritive sweeteners and sugar alcohols named in the ingredients (`sucralose`, `steviol_glycosides`, `erythritol`, …), dietary claims as stated (`Gluten-Free`, `Organic`, `Vegetarian`), an `organic` flag, caffeine statements and an `alcoholic_beverage` flag.
- **Warnings:** Proposition 65 notices, phenylketonuria statements and choking or heat cautions, verbatim.
### 2. Nutrition Data
A nutrition panel in rows, ready for per-serving calculations and scoring.
- **Nutrient rows:** `nutrition_nutrients` holds each printed row with `name`, `amount`, `unit` and `daily_value_percent`, with common label variants normalized (`Total Carbohydrate`, `Added Sugars`, `Vitamin D`).
- **Explicit basis:** `nutrition_basis` and `nutrition_preparation` say what the amounts refer to (`per_serving`, `per_100g`, `as_sold`, `as_prepared`), and `nutrition_serving_size` keeps the serving as printed. Values are never converted between bases.
- **Null is never a claim:** a missing row means the panel did not print it; a null allergen list means none was found, not allergen-free.
### 3. Machine Learning & Computer Vision
Pre-labelled images tied to structured ground truth.
- **Label reading:** 316 label photos (ingredient lists, nutrition panels, back of pack) paired with the transcribed ingredient statement, nutrient rows and allergen text of the same product, for training and evaluating OCR and vision-language extraction.
- **Product recognition:** main product images mapped to brand, name, category path and barcode for visual search and shelf-audit models.
- **Classification:** `product_type`, the `category` path, `food_condition`, `food_form` and `flavor` as targets.
### 4. E-commerce Enrichment (B2B)
Metadata designed to enrich product pages and power in-app scanning.
- **Barcode matching:** join the catalogue to your own inventory or a scanner app on the canonical GTIN-14 (pad the scanned code to 14 digits first).
- **Page enrichment:** ingredient lists, nutrition panels, allergen badges and dietary filters from one record.
- **Stable identity:** permanent integer ids and `updated_at` timestamps, so a later release can be diffed against this one by id.
---
## Technical Schema
The dataset is delivered in interchangeable **JSONL** and **CSV** formats. Every record is flat: each field is a scalar, a list, or one of two small structures (`nutrition_nutrients`, `ingredients_parsed`), so a product is one row everywhere. Null always means the fact was not stated by the source or could not be read; it is never a negative claim.
**Product fields**
| Field | Type | Nullable | Description |
|---|---|---|---|
| `id` | integer | no | Permanent product id. Gaps are normal; an id is never renumbered or reused, so it is safe to key on across releases. |
| `gtin` | string | no | Barcode in canonical GTIN-14 form (14 digits, left-zero-padded: UPC-A `28239002169` appears as `00028239002169`). Checksum-validated. |
| `name` | string | no | Product title as sold, including variant and package wording (`(4 pack) …`, `…, 16 oz`). |
| `brand` | string | no | Brand name. |
| `product_type` | string | no | `food` or `beverage`. |
| `category` | array<string> | no | Category path from broad to narrow, e.g. `["Food", "Snacks, Cookies & Chips", "Cookies"]`. |
| `net_content` | string | yes | Package quantity as printed, e.g. `16 oz`, `12 fl oz, 12 count`. |
| `pack_count` | integer | yes | Number of units in a multipack, when stated. |
| `food_condition` | string | yes | Storage condition as stated, lowercased: `shelf_stable`, `refrigerated`, `frozen`, `dry`, `ready-to-eat`, … |
| `food_form` | string | yes | Physical form as stated, lowercased, e.g. `whole`, `powder`, `liquid`. |
| `flavor` | string | yes | Flavor as stated. |
| `dietary_claims` | array<string> | yes | Claims as stated on the listing or pack, e.g. `Gluten-Free`, `Organic`, `Vegetarian`, `Natural`. |
| `organic` | boolean | yes | `true` when the product carries an organic claim; otherwise `null`, never `false`. |
| `ingredients` | string | no | The full ingredient statement as printed, with formatting cleaned but no words changed. |
| `ingredients_parsed` | array<object> | yes | The statement as a tree of components and ingredients in label order; see **Ingredient tree** below. Null when the statement could not be parsed reliably; the text is still in `ingredients`. |
| `sweeteners` | array<string> | yes | Non-nutritive sweeteners and sugar alcohols named in the ingredients, as identities in order of appearance: `aspartame`, `sucralose`, `acesulfame_potassium`, `saccharin`, `steviol_glycosides`, `monk_fruit_extract`, `erythritol`, `xylitol`, `sorbitol`, `maltitol`, `allulose`, … Sugars, syrups and honey are not listed. |
| `allergens_declared` | array<string> | yes | Allergens the package declares it contains (`Contains: …`), as identities: `milk`, `egg`, `wheat`, `soy`, `peanut`, `tree_nut`, `almond`, `cashew`, `walnut`, `pecan`, `hazelnut`, `pistachio`, `macadamia`, `brazil_nut`, `sesame`, `fish`, `shellfish`, `crustacean`, `mustard`, `celery`, `sulfite`, `coconut`, `gluten`. |
| `allergens_may_contain` | array<string> | yes | Precautionary allergens, same identities: `May contain …` claims and facility, equipment or line notes. |
| `allergens_statement` | string | yes | The allergen wording verbatim, including facility notes. |
| `nutrition_serving_size` | string | yes | Serving size as printed, e.g. `3 cookies (30g)`. |
| `nutrition_servings_per_container` | number | yes | Servings per container, when stated. |
| `nutrition_basis` | string | no | What the nutrient amounts refer to: `per_serving`, `per_100g`, `per_100ml`, or `unknown` when the source gave the rows without saying. |
| `nutrition_preparation` | string | no | Which panel column the rows come from: `as_sold`, `as_prepared`, or `unknown`. |
| `nutrition_nutrients` | array<object> | no | Nutrient rows in label order; see **Nutrient rows** below. Empty `[]` when no panel was available. |
| `caffeine_statement` | string | yes | The caffeine claim verbatim: `Caffeine-Free`, `Decaffeinated`, `Naturally Caffeinated`. |
| `caffeine_amount_mg`, `caffeine_basis` | — | yes | Reserved, always `null` in this version. |
| `alcoholic_beverage` | boolean | no | `true` when the product is an alcoholic beverage (a stated ABV of 0.5% or more, or listed as one). |
| `alcohol_percent` | number | yes | Alcohol by volume as stated, e.g. `4.7`. Null when not stated. |
| `warnings` | array<string> | yes | Package warnings verbatim: Proposition 65 notices, phenylketonuria statements, choking and heat cautions, allergen warning text. |
| `front_of_pack_warnings` | — | yes | Reserved, always `null` in this version. |
| `directions` | string | yes | Preparation, use and safe-handling instructions as supplied. |
| `countries_of_sale` | array<string> | no | ISO 3166 country codes where the product is sold, e.g. `["US"]`. |
| `additives`, `nutri_score`, `nova_group` | — | yes | Reserved, always `null` in this version. |
| `image_name` | string | yes | Filename of the main product image in `images/`; see **Images** below. |
| `label_image_names` | array<string> | yes | Filenames of the other package photos (ingredient list, nutrition panel, back of pack), in a fixed order without duplicates. |
| `source_name`, `source_url` | — | yes | Always `null`; no source attribution is published. |
| `updated_at` | string | no | ISO 8601 timestamp of the release in which this record's data last changed. |
**`nutrition_nutrients[]` object fields**
```json
{ "name": "Total Fat", "amount": 5, "unit": "g", "daily_value_percent": 6 }
```
| Field | Type | Nullable | Description |
|---|---|---|---|
| `name` | string | no | The row label as printed, with common variants normalized (`Total Carbohydrate`, `Added Sugars`, `Vitamin D`). |
| `amount` | number | yes | The printed quantity. A printed zero is `0`. A value not stated, or printed as a bound (`less than 1g`), is `null`. |
| `unit` | string | yes | The unit of `amount`: `g`, `mg`, `mcg`, and `kcal` for Calories. Null when `amount` is null. |
| `daily_value_percent` | number | yes | The printed % Daily Value, or `null` when none is printed. Rows that print only a % Daily Value (`Iron 4%`) have `amount` and `unit` null. |
Amounts refer to `nutrition_serving_size` when `nutrition_basis` is `per_serving`. A missing row means the panel did not print it, not zero.
**`ingredients_parsed[]` object fields (ingredient tree)**
```json
[
{
"component": null,
"ingredients": [
{ "name": "Sugar", "max_percent": null, "sub_ingredients": null },
{
"name": "Peanut Butter Chips",
"max_percent": null,
"sub_ingredients": [
{ "name": "Partially Defatted Peanuts", "max_percent": null, "sub_ingredients": null }
]
},
{ "name": "Salt", "max_percent": 2, "sub_ingredients": null }
]
}
]
```
Order follows the statement, which by regulation lists ingredients in descending order of weight.
| Field | Type | Nullable | Description |
|---|---|---|---|
| `component` | string | yes | A labelled part of the product (`Filling`, `Crust`, `Vitamins and Minerals`); null for a plain list. |
| `ingredients` | array<object> | no | The ingredients of that component, in label order. |
| `ingredients[].name` | string | no | The ingredient as printed. |
| `ingredients[].max_percent` | number | yes | Set from threshold wording (`Contains 2% or less of:`) on each ingredient it covers; an upper bound, not a measured share. Null otherwise. |
| `ingredients[].sub_ingredients` | array<object> | yes | The parenthesized ingredients of a compound ingredient, each with the same three fields (nesting continues as deep as the label does); null for a simple ingredient. |
### Format notes
**JSONL (`food_data.jsonl`).** One JSON object per line, records sorted ascending by `id`, keys in alphabetical order. Arrays stay arrays, objects stay objects, booleans stay booleans, nulls stay `null`. Preferred for programmatic use.
**CSV (`food_data.csv`).** The same products, one per row, in the same id order, with the same field names. UTF-8 without BOM, CRLF line endings, RFC 4180 quoting; embedded line breaks in text are replaced by spaces. Null is an empty cell. Booleans are the literal strings `True` / `False`. List and structured fields (`category`, `dietary_claims`, the `allergens_*` lists, `sweeteners`, `warnings`, `countries_of_sale`, `label_image_names`, `nutrition_nutrients`, `ingredients_parsed`) are stored as their JSON text, not split into columns. `gtin` keeps its leading zeros; open it as text, not a number.
```python
import pandas as pd, json
df = pd.read_json("food_data.jsonl", lines=True) # arrays and nested values stay native
df = pd.read_csv("food_data.csv", dtype={"gtin": str}, keep_default_na=False)
for c in ["category", "allergens_declared", "allergens_may_contain", "nutrition_nutrients", "ingredients_parsed"]:
df[c] = df[c].map(lambda s: json.loads(s) if s else None)
```
### Images
- Files live flat in `images/`, named by the SHA-256 of their bytes plus their format: `<sha256>.jpg`, `.png` or `.webp`. The same bytes always get the same name, so a photo shared by two listings is one file.
- `image_name` is the main product image; `label_image_names` lists the other package photos. Both hold bare filenames.
- Label photos are the source of the nutrition rows and allergen declarations on many products, so a consumer can check an extracted value against the package.
- 7 products have no main image (`image_name` is `null`); their records are complete, only the picture is absent.
---
## Notes and caveats
- **Values are as printed.** Ingredient statements, allergen wording, nutrient amounts, claims and warnings are transcribed from the listing and the package, not measured, scored or reinterpreted. Where a source and the package disagreed, the current package wins.
- **Null is not "no".** An absent allergen list, claim or warning means none was found in the sources, not that the product is free of it. Allergen identities are a reading aid, not a complete allergy assessment; `allergens_statement` carries the exact wording.
- **Nutrition rows are per the stated basis.** `nutrition_basis: "unknown"` means the source supplied the rows without a serving size, and the amounts should be read with that in mind.
- **One product, one record.** A listing that sells the same package under several item numbers appears once; multipacks are separate products with their own GTIN and `pack_count`.
- **No PII.** Product catalogue information only.
---
## Licensing
This sample dataset is provided under the **CC BY-NC 4.0** license for non-commercial research and evaluation.
**Commercial Access:** For production apps, commercial AI training or retail tools, a commercial license is required. The Food API launches with one-time dataset licenses (CSV, JSONL and SQLite snapshots with a full data dictionary) and a hosted API to follow. Visit [thefoodapi.io](https://thefoodapi.io) to join the waitlist for launch pricing and the full catalogue.
|