diff --git a/index.html b/index.html index f571118..69eb97c 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,19 @@
As a developer, the Open Food Facts API allows you to get information about existing products and contribute to the products database.
Using the API, you can create apps to help people make better food choices and also provide data to enhance the database.
Check out how others are making use of the API at https://world.openfoodfacts.org/discover#reuses.
The data contained in the Open Food Facts database are collected by users willing to selflessly contribute to the Open Food Facts initiative.
Therefore, no guarantees can be made for the accuracy, completeness, or reliability of the information provided. The user assumes the entire risk related to the use of data. You (or your users) are very welcome to provide fixes using the WRITE API.
You can use the Open Food Facts API for production use cases, as long as 1 API call equals 1 real scan by a user.
DART: GitHub - Package on pub.dev
Elixir: GitHub
Go: GitHub
NodeJS: GitHub
PHP: GitHub
PHP (Laravel): GitHub
Python: GitHub
React Native: GitHub
Ruby: GitHub
You can either use the global domain (https://world.openfoodfacts.org) or the local domains (https://fr.openfoodfacts.org, https://en.openfoodfacts.org …) for your API queries.
The Open Food Facts base API endpoint is https://world.openfoodfacts.org/api/2
The current version of the API is 2 .
READ and SEARCH operations
No authentication is required.
Add a User-Agent HTTP Header with the name of your app, the version, system and a url (if any), not to be blocked by mistake.
For example: User-Agent: NameOfYourApp - Android - Version 1.0 - www.yourappwebsite.com
WRITE operations
No authentication is required for adding new products or adding images.
Basic authentication is required for editing existing products. You can create a global account to let the users of your app contribute without having to create individual credentials in the Open Food Facts site.
See: 1.2 Authentication
You can do READ / SEARCH operations on the prod
environment running @ https://world.openfoodfacts.org.
You can do WRITE operations tests on the dev
environment running @ https://world.openfoodfacts.net (user:off
, password:off
).
Use the SSL version of the API: https://world.openfoodfacts.org
Disclaimer: The HTML code 404 is never thrown, even when a wrong password is entered. A feature request has been created and we are already working to fix this.
The API intended use is for apps, with one real user scan = one query. Automated queries are not supported. Please let us know in advance if you expect a high volume of calls.
For more information, see: https://world.openfoodfacts.org/data
Some queries (facets) are caches. Should you need to disable the cache, you can pass the nocache=1
parameter.
Using the fields=
parameter, you can reduce the response to only the fields you need.
The API development is in progress. This has several implications:
_t
are dates in the UNIX timestamp format (number of seconds since Jan 1st 1970)_datetime
are dates in the ISO8601 format: yyyy-mm-ddThh:mn:ssZ_tags
are comma-separated list of tags (e.g. categories_tags is the set of normalized tags computer from the categories field)_100g
correspond to the amount of a nutriment (in g) for 100 g or 100 ml of productDo not hesitate to file a bug if you find an issue in the API or need an improvement.
You can fill out the issue report on GitHub:
It is recommended to use the live API to get updated data about products. However, in some cases, you may need a snapshot.
They are available at:
API Redesign: The API is far from perfect. It’s been decided to fix the most urgent bugs and start planning for a new version, more compliant with modern API standards. We need all the help we can get. Please join us on the #api Slack channel.
As a developer, the Open Food Facts API allows you to get information about existing products and contribute to the products database.
Using the API, you can create apps to help people make better food choices and also provide data to enhance the database.
Check out how others are making use of the API at https://world.openfoodfacts.org/discover#reuses.
The data contained in the Open Food Facts database are collected by users willing to selflessly contribute to the Open Food Facts initiative.
Therefore, no guarantees can be made for the accuracy, completeness, or reliability of the information provided. The user assumes the entire risk related to the use of data. You (or your users) are very welcome to provide fixes using the WRITE API.
You can use the Open Food Facts API for production use cases, as long as 1 API call equals 1 real scan by a user.
You can either use the global domain (https://world.openfoodfacts.net) or the local domains (https://fr.openfoodfacts.net, https://en.openfoodfacts.net …) for your API queries.
The Open Food Facts base API endpoint is https://world.openfoodfacts.net/api/2
The current version of the API is 2 .
READ and SEARCH operations
No authentication is required.
Add a User-Agent HTTP Header with the name of your app, the version, system and a url (if any), not to be blocked by mistake.
For example: User-Agent: NameOfYourApp - Android - Version 1.0 - www.yourappwebsite.com
WRITE operations
No authentication is required for adding new products or adding images.
Basic authentication is required for editing existing products. You can create a global account to let the users of your app contribute without having to create individual credentials in the Open Food Facts site.
Parameters:
+* user_id
: YourUserID
+* password
: YourPassword
Checking you’re authentified
https://world.openfoodfacts.org/cgi/auth.pl
This endpoint returns status 200 or 403 if the user is authentified, either through the “session” cookie, or with the user_id and password parameters.
You can do READ / SEARCH operations on the prod
environment running @ https://world.openfoodfacts.org.
You can do WRITE operations tests on the dev
environment running @ https://world.openfoodfacts.net (user:off
, password:off
).
Use the SSL version of the API: https://world.openfoodfacts.net
Disclaimer: The HTML code 404 is never thrown, even when a wrong password is entered. A feature request has been created and we are already working to fix this.
The API intended use is for apps, with one real user scan = one query. Automated queries are not supported. Please let us know in advance if you expect a high volume of calls.
For more information, see: https://world.openfoodfacts.org/data
Some queries (facets) are caches. Should you need to disable the cache, you can pass the nocache=1
parameter.
Using the fields=
parameter, you can reduce the response to only the fields you need.
The API development is in progress. This has several implications:
_t
are dates in the UNIX timestamp format (number of seconds since Jan 1st 1970)_datetime
are dates in the ISO8601 format: yyyy-mm-ddThh:mn:ssZ_tags
are comma-separated list of tags (e.g. categories_tags is the set of normalized tags computer from the categories field)_100g
correspond to the amount of a nutriment (in g) for 100 g or 100 ml of productDo not hesitate to file a bug if you find an issue in the API or need an improvement. +You can fill out the issue report on GitHub:
It is recommended to use the live API to get updated data about products. However, in some cases, you may need a snapshot. +They are available at:
Example: https://us.openfoodfacts.org/data - (See the list of countries in the Countries taxonomy)
API Redesign: The API is far from perfect. It’s been decided to fix the most urgent bugs and start planning for a new version, more compliant with modern API standards. We need all the help we can get. Please join us on the #api Slack channel.
Get all products from Open Food Facts API.
Key | Value | Description |
---|---|---|
json | true |
Get all products from Open Food Facts API.
Key | Value | Description |
---|---|---|
json | true |
READ requests allow you to retrieve the nutritional data of a product with a barcode.
product/<BARCODE>
to locate the product by it’s barcode.product/<BARCODE>
to locate the product by it’s barcode.Get a country-specific nutrients ordered list. It changes based on country and is useful both to show a nutrition table or a nutrition input form.
Get a country-specific nutrients ordered list. It changes based on country and is useful both to show a nutrition table or a nutrition input form.
SEARCH requests allow you to retrieve the nutritional data of products that comply with your search criteria. Check out the examples below to see what you can do !
Important! The search feature works on whole words only, not parts of words. Your application should not have “search as you type” features that send search queries with parts of words, since this causes performance issues on the Open Food Facts server.
es.
prefix to get only Spanish products.json=true
to get a JSON response.Key | Value | Description |
---|---|---|
Content-Type | application/json |
Key | Value | Description |
---|---|---|
action | process | |
json | true |
es.
prefix to get only Spanish products.json=true
to get a JSON response.Key | Value | Description |
---|---|---|
Content-Type | application/json |
Key | Value | Description |
---|---|---|
action | process | |
json | true |
us.
prefix to get only US products.json=true
to get a JSON response.categories
filter to get only breakfast cereals.Key | Value | Description |
---|---|---|
action | process | |
tagtype_0 | categories | |
tag_contains_0 | contains | |
tag_0 | breakfast_cereals | |
json | true |
us.
prefix to get only US products.json=true
to get a JSON response.categories
filter to get only breakfast cereals.Key | Value | Description |
---|---|---|
action | process | |
tagtype_0 | categories | |
tag_contains_0 | contains | |
tag_0 | breakfast_cereals | |
json | true |
it.
prefix to get only Italian products.json=true
to get a JSON response.nutrition_grade
filter to get food with Nutriscore ‘A’Key | Value | Description |
---|---|---|
action | process | |
tagtype_1 | nutrition_grades | |
tag_contains_1 | contains | |
tag_1 | A | |
json | true |
it.
prefix to get only Italian products.json=true
to get a JSON response.nutrition_grade
filter to get food with Nutriscore ‘A’Key | Value | Description |
---|---|---|
action | process | |
tagtype_1 | nutrition_grades | |
tag_contains_1 | contains | |
tag_1 | A | |
json | true |
fr.
prefix to get only French products.json=true
to get a JSON response.categories
filter to get only breakfast cerealsnutrition_grade
filter to get food with Nutriscore ‘A’ingredients_from_palm_oil=without
to get food without palm oiladditives=without
to get food without additivesKey | Value | Description |
---|---|---|
action | process | |
tagtype_0 | categories | |
tag_contains_0 | contains | |
tag_0 | breakfast_cereals | |
tagtype_1 | nutrition_grades | |
tag_contains_1 | contains | |
tag_1 | A | |
ingredients_from_palm_oil | without | |
additives | without | |
json | true |
fr.
prefix to get only French products.json=true
to get a JSON response.categories
filter to get only breakfast cerealsnutrition_grade
filter to get food with Nutriscore ‘A’ingredients_from_palm_oil=without
to get food without palm oiladditives=without
to get food without additivesKey | Value | Description |
---|---|---|
action | process | |
tagtype_0 | categories | |
tag_contains_0 | contains | |
tag_0 | breakfast_cereals | |
tagtype_1 | nutrition_grades | |
tag_contains_1 | contains | |
tag_1 | A | |
ingredients_from_palm_oil | without | |
additives | without | |
json | true |
WRITE requests allow you to contribute new products and data to the Open Food Facts database.
Note: Please use the dev
environment https://world.openfoodfacts.net
for making test write calls (user:off
, password:off
). Remember to join the API channel on Slack before making a POST request !
Note:
Selecting, cropping and rotating photos are non-destructive actions. That means, the original version of the image uploaded to the system is kept as is. The subsequent changes made to the image are also stored as versions of the original image.
The actions described in this topic do not modify the image, but provide metadata on how to use it (the data of the corners in the case of selection and the data of the rotation). That is, you send an image to the API, provide an id, you define, for example, the cropping and rotation parameters and as a response, the server generates a new image as requested and you can call this new version of the image.
Key | Value | Description |
---|---|---|
code | 04963406 | |
user_id | test | |
password | test | |
brands | Häagen-Dazs | |
labels | kosher |
Key | Value | Description |
---|---|---|
code | 04963406 | |
user_id | test | |
password | test | |
brands | Häagen-Dazs | |
labels | kosher |
Photos are source and proof of data. When you upload an image to Open Food Facts, the image is stored as is. The first photo uploaded for a product is auto-selected as the product’s “front” photo.
Before uploading photos:
Image Quality: +https://us.openfoodfacts.net/cgi/product_jqm2.pl
Photos are source and proof of data. When you upload an image to Open Food Facts, the image is stored as is. The first photo uploaded for a product is auto-selected as the product’s “front” photo.
Before uploading photos:
Image Quality: Uploading quality photos of a product, its ingredients and nutrition table is very important, since it allows the Open Food Facts OCR system to retrieve important data to analyze the product. The minimal allowed size for photos is 640 x 160 px.
Upload Behavior: In case you upload more than one photo of the front, the ingredients and the nutrition facts, beware that only the first photo of each category will be displayed. (You might want to take additional images of labels, recycling instructions, and so on). All photos will be saved.
Label Languages: Multilingual products have several photos based on languages present on the packaging. You can specify the language by adding a lang code suffix to the request.
Product Image Upload (Perl):
The API route is product_image_upload.pl
and you can specify from which perspective the photo was taken, by sending the imagefield to precise the angle, AND the image as a Multipart response in the matching field.
Parameters:
code
: the barcode of the productimagefield
: (can be either: front | ingredients | nutrition | packaging)imgupload_front
: your image file if imagefield=frontimgupload_ingredients
: your image file if imagefield=ingredientsimgupload_nutrition
: your image file if imagefield=nutritionimgupload_packaging
: your image file if imagefield=packagingKey | Value | Description |
---|---|---|
code | 04963406 | |
product_image_upload.pl/imgupload_front | cheeriosfrontphoto.jpg |
Note: Cropping is only relevant for editing existing products. You cannot crop an image the first time you upload it to the system.
Key | Value | Description |
---|---|---|
code | 04963406 | |
imgid | 2 | |
id | front_en | |
x1 | 0 | |
y1 | 0 | |
x2 | 145 | |
y2 | 145 |
Note: Cropping is only relevant for editing existing products. You cannot crop an image the first time you upload it to the system.
Key | Value | Description |
---|---|---|
code | 04963406 | |
imgid | 2 | |
id | front_en | |
x1 | 0 | |
y1 | 0 | |
x2 | 145 | |
y2 | 145 |
Although we recommend rotating photos manually and uploading a new version of the image, the OFF API allows you make api calls to automate this process.
You can rotate existing photos by setting angle
to 90
º, 180
º or 270
º clockwise.
Example:
POST https://world.openfoodfacts.org/cgi/product_image_crop.pl?code=3266110700910&id=nutrition_fr&imgid=1&angle=90
Key | Value | Description |
---|---|---|
code | 04963406 | |
id | nutrition_fr | |
imgid | 1 | |
angle | 90 |
Although we recommend rotating photos manually and uploading a new version of the image, the OFF API allows you make api calls to automate this process.
You can rotate existing photos by setting angle
to 90
º, 180
º or 270
º clockwise.
Example:
POST https://world.openfoodfacts.org/cgi/product_image_crop.pl?code=3266110700910&id=nutrition_fr&imgid=1&angle=90
Key | Value | Description |
---|---|---|
code | 04963406 | |
id | nutrition_fr | |
imgid | 1 | |
angle | 90 |
You have to deselect photos to remove languages that are not relevant to the product.
[DOCUMENTATION TBA]
Open Food Facts uses optical character recognition (OCR) to retrieve nutritional data and other information from the product labels.
process_image=1
)Notes: +https://world.openfoodfacts.net/cgi/ingredients.pl
Open Food Facts uses optical character recognition (OCR) to retrieve nutritional data and other information from the product labels.
process_image=1
)Notes: * The OCR may contain errors. Encourage your users to correct the output using the ingredients WRITE API. -* You can also use your own OCR, especially if to plan to send a high number of queries.
We recommend Google’s Vision API to detect and extract text from the images.
For more information about this product, see: https://cloud.google.com/vision/docs/ocr?hl=en
Set ocr_engine=google_cloud_vision
to use it.
Key | Value | Description |
---|---|---|
code | 04963406 | |
id | ingredients_fr | |
process_image | 1 | |
ocr_engine | google_cloud_vision |
@@ -25536,7 +25541,7 @@
“packaging”
How to convert seconds in human readable format: 83734290 = 2 years and 7 months (example routine to convert) - https://stackoverflow.com/questions/29681328/convert-seconds-into-years-months-weeks-hours-minutes-and-seconds
Key | Value | Description |
---|---|---|
fields | images_to_update_fr |
Advanced filtering is available to make fine-grained requests to the API.
This section includes the parameters you can add to make READ
/ SEARCH
/ WRITE
requests.
Country code
A country code is prefixed to the domain name openfoodfacts.org
, e.g: fr.
: it allows filtering all products from a specific country.
You can use world.
to display products from all over the world or use one of the Alpha 2 codes as per ISO-3166-1.
Examples: +
This section includes the parameters you can add to make READ
/ SEARCH
/ WRITE
requests.
Country code
A country code is prefixed to the domain name openfoodfacts.net
, e.g: fr.
: it allows filtering all products from a specific country.
You can use world.
to display products from all over the world or use one of the Alpha 2 codes as per ISO-3166-1.
Examples:
- United States: us
- France: fr
- Spain: es
You can find the full list of supported country codes in the Countries taxonomy.
Important! Using a specific country code will also change the naming of the response fields, see language code.
Language code
A language code can be added after the country code to specify the language of the response fields, e.g: https://<cc>-<lc>.openfoodfacts.org
Example:
https://fr.openfoodfacts.org/categorie/pizzas.json
Example 2:
https://fr-en.openfoodfacts.org/category/pizzas.json
The language codes supported are based on the ISO Standards 639-1.
You can find the full list of supported language codes in the Languages taxonomy.
API Version
Current version number of the Open Food Facts API. For now, only version 0 is available. To be represented as: /api/v0
Results per page
page_size
# page_size
20
# 2050
# 50100
# 100250
# 250500
# 5001000
# 1000Pagination
page=1
Format
json=true
(recommended)xml=true
Output fields
Filtering the output fields reduces the payload size, the bandwith needed and the download time. To filter the fields, simply add the “fields” parameter to your search query. Example to retrieve only the generic_name
: https://world.openpetfoodfacts.org/api/v0/product/20106836.json?fields=generic_name
General information:
code
: barcode of the product (can be EAN-13 or internal codes for some food stores). For products without a barcode, Open Food Facts assigns a number starting with the 200 reserved prefix.url
: url of the product page on Open Food Facts.creator
: contributor who first added the product.created_t
: date when the product was added (UNIX timestamp format).created_datetime
: date when the product was added (ISO8601 format: yyyy-mm-ddThh:mn:ssZ).last_modified_t
: date when the product page was last modified.last_modified_datetime
: date and time when the product was last modified.product_name
: name of the product.generic_name
: legal name of the product as regulated by the European authorities.quantity
: quantity and unit.Ingredients:
ingredients_text
traces
: List of substances that might cause allergies that are present in trace amount in the product (this does not include the ingredients, as they are not only present in trace amount). It is taxonomized with the allergens taxonomy.traces_tags
Packages:
packaging
: shape, material. Example: Cardboardpackaging_tags
emb_codes
: packager code. Example: EMB 2013330emb_codes_tags
Brands:
brands
brands_tags
Categories:
categories
categories_tags
Location:
origins
: origins of ingredientsorigins_tags
first_packaging_code_geo
: coordinates corresponding to the first packaging code.manufacturing_places
: places where the product was manufactured or transformed.manufacturing_places_tags
cities
cities_tags
purchase_places
: country, state and/or city where the product can be purchased. For example: Paris, France.stores
: distributor name. Example: Tesco, Walmart, Carrefour.countries
: list of countries where the product is sold.countries_tags
Labels
labels
: Example: vegan, fat free, Kosher.labels_tags
Producer
producer
producer_product_id
producer_version_id
Value and Weight
net_weight_value
net_weight_unit
drained_weight_value
drained_weight_unit
volume_value
volume_unit
Images
image_url
image_small_url
: simplified version of the url.Energy
Legacy
energy_unit
: (string). The unit used in the energy_value
field (example in JSON: “energy_unit”:“kJ”). Possible values are “kJ” or “kcal”.energy_value
: (string). The standardized value of a serving of 100g (or 100ml for liquids) for energy expressed in the unit specified in the field energy_unit
(example in JSON: “energy_value”:“190”).Preferred method
energy-kj_unit
: (string). The unit used in the field energy-kj_value (example in JSON: “energy_unit”:“kJ”). The only possible value is “kJ”;energy-kj_value
: (string). The standardized value of a serving of 100g (or 100ml for liquids) for energy expressed in kJ (example in JSON: “energy-kj_value”:“190”).energy-kcal_unit
: (string). The unit used in the field energy-kcal_unit (example in JSON: “energy_unit”:“kcal”). The only possible value is “kcal”;energy-kcal_value
: (string). The standardized value of a serving of 100g (or 100ml for liquids) for energy expressed in kcal (example in JSON: “energy-kcal_value”:“190”).According to the European regulation, the ratio between values calculated in kJ and values calculated in kcal may differ from the standard conversion ratio of 4.184 (because of carried rounding errors). Both values might appear on the same product. In that case, the value in kJ will be the one returned in the legacy energy_unit
and energy_value
fields. If only one unit was provided (kJ or kcal), this unit will be returned in the legacy energy_unit
and energy_value
fields.
Additives:
additives_n
: number of food additivesadditives
additives_tags
Miscellaneous:
serving_size
: serving size in g (or ml)serving_quantity
no_nutriments
: indicates if the nutrition facts are shown on the product label.ingredients_text
allergens
traces
ingredients_from_palm_oil_n
ingredients_from_palm_oil
ingredients_from_palm_oil_tags
ingredients_that_may_be_from_palm_oil_n
ingredients_that_may_be_from_palm_oil
ingredients_that_may_be_from_palm_oil_tags
nutrition_grade_fr
: nutrition grade (‘a’ to ‘e’). see https://world.openfoodfacts.org/nutriscoremain_category
other_information
conservation_conditions
: Example: Keep in a dry place.recycling_instructions_to_recycle
recycling_instructions_to_discard
nutrition_grade_fr_producer
: declarative (printed on the packaging)recipe_idea
customer_service
: contact info of customer service.preparation
: how to cook the food: microwave, oven, which temperature…warning
: regulatory warning. Example: contains sorbitol.data_sources
: source of data imported from producers.nova_group
: system of grades for comparing the degree of processing of products. For more information, see: https://world.openfoodfacts.org/novapnns_groups_1
: disregard. Used to improve the nutriscore calculation.pnns_groups_2
: disregard. Used to improve the nutriscore calculation.states
: if the product is complete or if there is any information missing.Environment -The Eco-Score needs to be queried according to the country of the user. -Due to the recent nature of the Eco-Score, the full APIs are documented in a separate document. -https://docs.google.com/document/d/1_5AeofpXbaKY9Rd3eeWmHIrhJE8GiPQ-Mfx1SCvpzME/edit?usp=sharing
Other nutrition keys
carbon-footprint_100g
: carbon footprint (indicated on some products). The unit is absolute grams of C02.ph_100g
: pH (no unit)cocoa
: minimal cacao content of the product in %. Important!: Note the typo.fruits-vegetables-nuts_100g
: % of fruits, vegetables and nuts (excluding potatoes, yams, manioc)nutrition-score-fr_100g
: experimental nutrition score derived from the UK FSA score and adapted for the French market (formula defined by the team of Professor Hercberg)nutrition-score-uk_100g
: nutrition score defined by the UK Food Standards Administration (FSA).
-For more information about the difference between the fr
and uk
nutri-scores see the FAQ section of this documentation.General information:
code
: barcode of the product (can be EAN-13 or internal codes for some food stores). For products without a barcode, Open Food Facts assigns a number starting with the 200 reserved prefix.url
: url of the product page on Open Food Facts.creator
: contributor who first added the product.created_t
: date when the product was added (UNIX timestamp format).created_datetime
: date when the product was added (ISO8601 format: yyyy-mm-ddThh:mn:ssZ).last_modified_t
: date when the product page was last modified.last_modified_datetime
: date and time when the product was last modified.product_name
: name of the product.generic_name
: legal name of the product as regulated by the European authorities.quantity
: quantity and unit.Ingredients:
ingredients_text
: Raw list of ingredients. This will get automatically parsed and get used to compute the Eco-Score. You can either request if (if it exists) or send it in a specific language, e.g: ingredients_text_en
traces
: List of substances that might cause allergies that are present in trace amount in the product (this does not include the ingredients, as they are not only present in trace amount). It is taxonomized with the allergens taxonomy.traces_tags
Packages:
packaging
: shape, material. Example: Cardboardpackaging_tags
packaging_text
: Recycling instructions as raw text eg: “Plastic bottle to recycle, Plastic cap to recycle”. This will get automatically parsed and get used to compute the Eco-Score. You can either request if (if it exists) or send it in a specific language, e.g: packaging_text_en
for the above exampleemb_codes
: packager code. Example: EMB 2013330emb_codes_tags
Brands:
brands
brands_tags
Categories:
categories
categories_tags
Location:
origins
: origins of ingredientsorigins_tags
first_packaging_code_geo
: coordinates corresponding to the first packaging code.manufacturing_places
: places where the product was manufactured or transformed.manufacturing_places_tags
cities
cities_tags
purchase_places
: country, state and/or city where the product can be purchased. For example: Paris, France.stores
: distributor name. Example: Tesco, Walmart, Carrefour.countries
: list of countries where the product is sold.countries_tags
Labels
labels
: Example: vegan, fat free, Kosher.labels_tags
Producer
producer
producer_product_id
producer_version_id
Value and Weight
net_weight_value
net_weight_unit
drained_weight_value
drained_weight_unit
volume_value
volume_unit
Images
image_url
image_small_url
: simplified version of the url.Energy
energy_unit
: (string). The unit used in the energy_value
field (example in JSON: “energy_unit”:“kJ”). Possible values are “kJ” or “kcal”.energy_value
: (string). The standardized value of a serving of 100g (or 100ml for liquids) for energy expressed in the unit specified in the field energy_unit
(example in JSON: “energy_value”:“190”).energy-kj_unit
: (string). The unit used in the field energy-kj_value (example in JSON: “energy_unit”:“kJ”). The only possible value is “kJ”;energy-kj_value
: (string). The standardized value of a serving of 100g (or 100ml for liquids) for energy expressed in kJ (example in JSON: “energy-kj_value”:“190”).energy-kcal_unit
: (string). The unit used in the field energy-kcal_unit (example in JSON: “energy_unit”:“kcal”). The only possible value is “kcal”;energy-kcal_value
: (string). The standardized value of a serving of 100g (or 100ml for liquids) for energy expressed in kcal (example in JSON: “energy-kcal_value”:“190”).According to the European regulation, the ratio between values calculated in kJ and values calculated in kcal may differ from the standard conversion ratio of 4.184 (because of carried rounding errors). Both values might appear on the same product. In that case, the value in kJ will be the one returned in the legacy energy_unit
and energy_value
fields. If only one unit was provided (kJ or kcal), this unit will be returned in the legacy energy_unit
and energy_value
fields.
Additives:
additives_n
: number of food additivesadditives
additives_tags
Miscellaneous:
serving_size
: serving size in g (or ml)serving_quantity
no_nutriments
: indicates if the nutrition facts are shown on the product label.ingredients_text
allergens
traces
ingredients_from_palm_oil_n
ingredients_from_palm_oil
ingredients_from_palm_oil_tags
ingredients_that_may_be_from_palm_oil_n
ingredients_that_may_be_from_palm_oil
ingredients_that_may_be_from_palm_oil_tags
nutrition_grade_fr
: nutrition grade (‘a’ to ‘e’). see https://world.openfoodfacts.org/nutriscoremain_category
other_information
conservation_conditions
: Example: Keep in a dry place.recycling_instructions_to_recycle
recycling_instructions_to_discard
nutrition_grade_fr_producer
: declarative (printed on the packaging)recipe_idea
customer_service
: contact info of customer service.preparation
: how to cook the food: microwave, oven, which temperature…warning
: regulatory warning. Example: contains sorbitol.data_sources
: source of data imported from producers.nova_group
: system of grades for comparing the degree of processing of products. For more information, see: https://world.openfoodfacts.org/novapnns_groups_1
: disregard. Used to improve the nutriscore calculation.pnns_groups_2
: disregard. Used to improve the nutriscore calculation.states
: if the product is complete or if there is any information missing.Environment
The Eco-Score needs to be queried according to the country of the user.
Due to the recent nature of the Eco-Score, the full APIs are documented in a separate document.
https://docs.google.com/document/d/1_5AeofpXbaKY9Rd3eeWmHIrhJE8GiPQ-Mfx1SCvpzME/edit?usp=sharing
Other nutrition keys
carbon-footprint_100g
: carbon footprint (indicated on some products). The unit is absolute grams of C02.ph_100g
: pH (no unit)cocoa
: minimal cacao content of the product in %. Important!: Note the typo.fruits-vegetables-nuts_100g
: % of fruits, vegetables and nuts (excluding potatoes, yams, manioc)nutrition-score-fr_100g
: experimental nutrition score derived from the UK FSA score and adapted for the French market (formula defined by the team of Professor Hercberg)nutrition-score-uk_100g
: nutrition score defined by the UK Food Standards Administration (FSA).fr
and uk
nutri-scores see the FAQ section of this documentation.Each nutrition fact consists of multiple fields which are represented by a key. The fields can also be found in the taxonomy translation file.
Field names are built by concatenating 3 concepts:
Example 1: 3.4 g of carbohydrates in the product as sold for 100g should be represented as:
carbohydrates_100g
: 3.4
Example 2: 12 mg of zinc in the prepared product for a serving of 125 mL should be defined as:
zinc_prepared_serving
: 0.012
Important: * Only the nutrition facts that are actually found on the packaging are present in the interface. @@ -25613,11 +25614,11 @@
A facet refers to all the values that contributors add to a property. A facet includes the values defined in the taxonomy and the new values added by the contributors. Facet change constantly and their values are not validated. Facets vary by country.
Facet queries can be made to retrieve a list of the values that belong to a specific facet (for example, labels) and its product count.
A facet query has the following structure:
https://world.openfoodfacts.org/allergens.json
You can replace world
with any of the country codes described in the Countries taxonomy.
The values of the facet that are not included in the taxonomy are marked with an asterisk (*).
See an example here: https://us.openfoodfacts.org/labels
A category is a “tag” used to classify foods in different groups. For example, cheeses. Categories can be freely entered by users. Food category is one of the facets of Open Food Facts. Other examples are allergens or additives.
Note that there is also a taxonomy of categories used to define as many as possible of the “tags” entered by users as known entries in the taxonomy.
The following query retrieves a list of all categories available:
https://world.openfoodfacts.org/categories.json
You can retrieve a list of products that belong to a specific category. For example, “cheeses”:
https://world.openfoodfacts.org/category/cheeses.json
Note that the query has an additional parameter “category”.
Important! The categories hierarchy is not a tree but a lattice: each node can have several children, but also several parents.
Query allergens facet.
See examples below for taxonomy and other queries.
Query allergens facet.
See examples below for taxonomy and other queries.
Query additives facet.
See examples below for taxonomy and other queries.
The response includes the code and name of the additive, a link to a Wikipedia page with more information about the additive, and the number of products containing this additive in the Open Food Facts database.
Query additives facet.
See examples below for taxonomy and other queries.
The response includes the code and name of the additive, a link to a Wikipedia page with more information about the additive, and the number of products containing this additive in the Open Food Facts database.
Query additives classes taxonomy.
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Query additives classes taxonomy.
Key | Value | Description |
---|---|---|
Content-Type | application/json |
Query brands facet.
See examples below for taxonomy and other queries.
Query brands facet.
See examples below for taxonomy and other queries.
Query countries facet.
See examples below for taxonomy and other queries.
The only country code accepted for queries to the API is ‘country_code_2’. The other formats are only provided for your convenience. Those are the country codes for Top Level Domains.
Query countries facet.
See examples below for taxonomy and other queries.
The only country code accepted for queries to the API is ‘country_code_2’. The other formats are only provided for your convenience. Those are the country codes for Top Level Domains.
Query ingredients facet.
See examples below for taxonomy and other queries.
Query ingredients facet.
See examples below for taxonomy and other queries.
Query ingredients taxonomy.
This request is used to get information about absence or unawareness of the presence of:
Palm oil free
, Palm oil
, Palm oil content unknown
, may-contain-palm-oil
vegetarian
, non-vegetarian
, vegetarian-status-unknown
, maybe-vegetarian
.vegan
, non-vegan
, vegan-status-unknown
, maybe-vegan
.Important! Parsing might not be perfect and the ingredient detection might have issues in some languages. For more information on how the translation works, see: https://github.com/openfoodfacts/openfoodfacts-server/blob/master/taxonomies/ingredients.txt
Query ingredients taxonomy.
This request is used to get information about absence or unawareness of the presence of:
Palm oil free
, Palm oil
, Palm oil content unknown
, may-contain-palm-oil
vegetarian
, non-vegetarian
, vegetarian-status-unknown
, maybe-vegetarian
.vegan
, non-vegan
, vegan-status-unknown
, maybe-vegan
.Important! Parsing might not be perfect and the ingredient detection might have issues in some languages. For more information on how the translation works, see: https://github.com/openfoodfacts/openfoodfacts-server/blob/master/taxonomies/ingredients.txt
Query languages facet.
See examples below for taxonomy and other queries.
Query languages facet.
See examples below for taxonomy and other queries.
Query nova groups taxonomy.
Query nova groups taxonomy.
Open Food Facts uses optical character recognition (OCR) to retrieve nutritional data and other information from the product labels.
process_image=1
)Notes: +https://world.openfoodfacts.net/cgi/nutrients.pl
Open Food Facts uses optical character recognition (OCR) to retrieve nutritional data and other information from the product labels.
process_image=1
)Notes: * The OCR may contain errors. Encourage your users to correct the output using the ingredients WRITE API. * You can also use your own OCR, especially if to plan to send a high number of queries.
We recommend Google’s Vision API to detect and extract text from the images.
For more information about this product, see: https://cloud.google.com/vision/docs/ocr?hl=en
Set ocr_engine=google_cloud_vision
to use it.
Key | Value | Description |
---|---|---|
code | 04963406 | |
id | ingredients_fr | |
process_image | 1 | |
ocr_engine | google_cloud_vision |
Query nutrient levels taxonomy.
The nutrient levels indicate the quantity of fat, saturated fat, sugar and salt in a product.
The quantity levels are the following:
For more information about the quantity levels, read the annex 3 of the guide on the development of front of pack nutrition labels, issued by the Department of Health of the British Government, the Food Standards Agency, and devolved administrations in Scotland, Northern Ireland and Wales in collaboration with the British Retail Consortium. +https://world.openfoodfacts.net/data/taxonomies/nutrient_levels.json
Query nutrient levels taxonomy.
The nutrient levels indicate the quantity of fat, saturated fat, sugar and salt in a product.
The quantity levels are the following:
For more information about the quantity levels, read the annex 3 of the guide on the development of front of pack nutrition labels, issued by the Department of Health of the British Government, the Food Standards Agency, and devolved administrations in Scotland, Northern Ireland and Wales in collaboration with the British Retail Consortium. Annex 3. Determining red, amber and green colour coding (and High, Medium and Low (HML) text if applied): https://www.food.gov.uk/sites/default/files/media/document/fop-guidance_0.pdf
Examples:
You can use the following query to retrieve the states taxonomy:
GET https://world.openfoodfacts.org/data/taxonomies/states.json
+https://world.openfoodfacts.net/states.json
You can use the following query to retrieve the states taxonomy:
GET https://world.openfoodfacts.org/data/taxonomies/states.json
Use the following query to retrieve the states facet:
GET https://world.openfoodfacts.org/states.json
You can drill-down to the list of products in a certain state by making the following call:
GET https://world.openfoodfacts.org/state/statename.json
Example:
To retrieve a list of products with photo, you can make the following request:
GET https://world.openfoodfacts.org/state/photos-uploaded.json
@@ -544232,7 +544233,7 @@
Query the stores taxonomy
Query the stores taxonomy
Meet Dave.
Dave is an active Open Food Facts contributor and a developer who wants to build HealthyFoodChoices, an Android app aimed at conscious consumers that buy healthy products.
HealthyFoodChoices will query Open Food Facts API and provide information on healthy foods available in the place users are living in. Users can narrow down the results by applying different filters and save their search criteria so that the app shows them the products that match their preferences next time they use it.
To identify the potential users’ needs, Dave has met with some conscious consumers.
Anna is a 25-year old New Yorker who doesn’t drink soda, but her nephew does. She wants to compare the nutrition facts of two cola brands, and its variants (diet
, zero
, and so on) to decide which one to buy.
Stefano is a 36-year old Italian who follows a plant-based diet and wants to avoid the intake of palm oil. He’s looking for a breakfast cereal brand that does not use palm oil nor additives and has a great nutriscore (A).
Dave wants his app to make an API call to provide Anna the information she needs to make a conscious choice when buying sodas.
To make the API query that returns the products that might be interesting for Anna, Dave doesn’t need to authenticate (READ
request).
However, he has to add a User-Agent
HTTP Header with the name of his app, the version, system and a url (if any), so that he doesn’t get blocked by mistake.
In this case, that would be: User-Agent: HealthyFoodChoices - Android - Version 1.0
Since Anna lives in NY, Dave wants to define the subdomain for the query as us
. The subdomain automatically defines the country code (cc
) and language of the interface (lc
).
The country code determines that only the products sold in the US are displayed. The language of the interface for the country code us
is English.
In this case:
The current version number of the Open Food Facts API is v0.
https://us.openfoodfacts.org/api/v0
After the version number, the word “product”, followed by its barcode must be added:
https://us.openfoodfacts.org/api/v0/product/ The app will provide Anna with information about additives, sugars and nutriscore of different types of colas, to help her make her purchase decision. Anna selects the products she wants to compare in the application (Coca-Cola, Pepsi, Coca-Cola diet, Coca-Cola zero and Pepsi diet). The app retrieves the corresponding barcodes and makes the following calls: Pepsico Pepsi Cola Soda:
@@ -554903,34 +554904,34 @@
Example: https://robotoff.openfoodfacts.org/api/v1/questions/3274570800026?lang=en&count=3 Display the question and possible answers in the UI. Send back the proper ping to the Open Food Facts server if the user answers. https://github.com/openfoodfacts/robotoff/blob/master/doc/api.md Fetch a random insight. str, optional - comma-separated list, the type of insight. If not provided, an insight from any type will be returned. str, optional - server domain. Default to ‘api.openfoodfacts.org’ str, optional - number of results to return (default: 1) str, optional - filter by value tag, i.e the value that is going to be sent to Openfoodfacts str, optional - Only return predictions with products from a specific country (ex: en:france) (string, optional): filter by brands, comma-separated list of brand tags. Fetch a random insight. str, optional - comma-separated list, the type of insight. If not provided, an insight from any type will be returned. str, optional - server domain. Default to ‘api.openfoodfacts.org’ str, optional - number of results to return (default: 1) str, optional - filter by value tag, i.e the value that is going to be sent to Openfoodfacts str, optional - Only return predictions with products from a specific country (ex: en:france) (string, optional): filter by brands, comma-separated list of brand tags. Return all insights associated with a specific product. Optional. Allows to get all insights for a product The language the response is served in, useful to get translated questions to ask users Domain it’s queried from number of insight you’d like packaging, category, label, brand,product_weight In some cases, you might want the nth page of insights Return all insights associated with a specific product. Optional. Allows to get all insights for a product The language the response is served in, useful to get translated questions to ask users Domain it’s queried from number of insight you’d like packaging, category, label, brand,product_weight In some cases, you might want the nth page of insights ID of the insight ID of the insight Submit an annotation, given the Submit an annotation, given the (str, required) - ID of the insight (int, required) - Annotation of the prediction: 1 to accept the prediction, 0 to refuse it, and -1 for “unknown”. (int, optional) - Send the update to Openfoodfacts if update=1, don’t send the update otherwise. This parameter is useful if the update is performed client-side. You can get questions for a given product or get random questions. (str, optional) - the language of the question/value. ‘en’ by default. (int, optional) - Number of questions to return. Default to 1. (str, optional) - server domain. Default to ‘api.openfoodfacts.org’ Product barcode You can get questions for a given product or get random questions. (str, optional) - the language of the question/value. ‘en’ by default. (int, optional) - Number of questions to return. Default to 1. (str, optional) - server domain. Default to ‘api.openfoodfacts.org’ Product barcode Open Food Facts username Open Food Facts username This API was a Christmas present from Raphael to Pierre{"questions": [{"barcode": "3274570800026", "type": "add-binary", "value": "Scallop", "question": "Does the product belong to this category?", "insight_id": "5cac03bc-a5a7-4ec2-a548-17fd9319fee7", "insight_type": "category", "source_image_url": "https://static.openfoodfacts.org/images/products/327/457/080/0026/front_en.4.400.jpg"}], "status": "found"}
Description
Parameters
type
(string, optional): The type of insight. If not provided, an insight from any type will be returned.country
(string, optional): Only return predictions with products from a specific country (ex: en:france)value_tag
(string, optional): Filter by value tag, i.e the value that is going to be sent to Open Food Facts.server_domain
(string, optional): Server domain. Default to ‘api.openfoodfacts.org’Query
Key Value Description lang fr insight_types category server_domain api.openfoodfacts.org count 10 value_tag en:bcaa country en:france brands ironmaxx Description
Parameters
type
(string, optional): The type of insight. If not provided, an insight from any type will be returned.country
(string, optional): Only return predictions with products from a specific country (ex: en:france)value_tag
(string, optional): Filter by value tag, i.e the value that is going to be sent to Open Food Facts.server_domain
(string, optional): Server domain. Default to ‘api.openfoodfacts.org’Query
Key Value Description lang fr insight_types category server_domain api.openfoodfacts.org count 10 value_tag en:bcaa country en:france brands ironmaxx Description
Parameters
barcode
: Product barcodeserver_domain
(string, optional) - server domain. Default to ‘api.openfoodfacts.org’Query
Key Value Description barcode 0021000123803 lang fr server_domain api.openfoodfacts.org count 50 insight_types packaging page 1 Description
Parameters
barcode
: Product barcodeserver_domain
(string, optional) - server domain. Default to ‘api.openfoodfacts.org’Query
Key Value Description barcode 0021000123803 lang fr server_domain api.openfoodfacts.org count 50 insight_types packaging page 1 Description
Parameters
insight_id
: ID of the insightQuery
Key Value Description id 23541d80-02fc-4cd6-88eb-d93aa17e3386 Description
Parameters
insight_id
: ID of the insightQuery
Key Value Description id 23541d80-02fc-4cd6-88eb-d93aa17e3386 Description
insight_id
. The request type must be application/x-www-form-urlencoded.Parameters
insight_id
(string, required): ID of the insightannotation
(integer, required):
+https://robotoff.openfoodfacts.net/api/{{ROBOTOFF_API_VERSION}/insights/annotateDescription
insight_id
. The request type must be application/x-www-form-urlencoded.Parameters
insight_id
(string, required): ID of the insightannotation
(integer, required):
Annotation of the prediction:update
(integer, optional): Send the update to Open Food Facts if update=1. Otherwise, the update won’t be sent. This parameter is useful if the update is performed client-side.Query
Key Value Description insight_id 23541d80-02fc-4cd6-88eb-d93aa17e3386 annotation 0 update false Description
Parameters to be used to get questions for a given product
barcode
: Product barcodelang
(string, optional): the language of the question/value. Default: en.count
(integer, optional): Number of questions to return. Default: 1.server_domain
(string, optional): server domain. Default: ‘api.openfoodfacts.org’Parameters to be used to get random questions
lang
(string, optional): the language of the question/value. Default: en.count
(integer, optional): Number of questions to return. Default: 1.insight_types
(list, optional): comma-separated list, filter by insight types.country
(string, optional): filter by country tag.brands
(string, optional): filter by brands, comma-separated list of brand tags.value_tag
(string, optional): filter by value tag, i.e the value that is going to be sent to Openfoodfacts.server_domain
(string, optional): server domain. Default: api.openfoodfacts.org.Query
Key Value Description lang fr count 10 server_domain api.openfoodfacts.org barcode 0021000123803 Description
Parameters to be used to get questions for a given product
barcode
: Product barcodelang
(string, optional): the language of the question/value. Default: en.count
(integer, optional): Number of questions to return. Default: 1.server_domain
(string, optional): server domain. Default: ‘api.openfoodfacts.org’Parameters to be used to get random questions
lang
(string, optional): the language of the question/value. Default: en.count
(integer, optional): Number of questions to return. Default: 1.insight_types
(list, optional): comma-separated list, filter by insight types.country
(string, optional): filter by country tag.brands
(string, optional): filter by brands, comma-separated list of brand tags.value_tag
(string, optional): filter by value tag, i.e the value that is going to be sent to Openfoodfacts.server_domain
(string, optional): server domain. Default: api.openfoodfacts.org.Query
Key Value Description lang fr count 10 server_domain api.openfoodfacts.org barcode 0021000123803 Query
Key Value Description username Query
Key Value Description username Query
Key Value Description image_url https://static.openfoodfacts.org/images/products/317/718/000/0810/1.jpg y_min 0.758063614 x_min 0.888398051 y_max 0.993165255 x_max 0.994514585 Query
Key Value Description image_url https://static.openfoodfacts.org/images/products/317/718/000/0810/1.jpg y_min 0.758063614 x_min 0.888398051 y_max 0.993165255 x_max 0.994514585 Description
Query
Key Value Description count 5