Skip to content

Adding missing products

Dave regularly adds new products to the database and completes missing information via API calls. He has described the process below to show other developers how easy it is to contribute.


Authentication and Header#

If you have an app that makes POST calls and you don't want your users to authenticate in Open Food Facts, you can create a global account. Dave has created a global account for the app he is developing with the following credentials:

  • user_id: myappname
  • password: 123456
  • For a complete reference on AUTH, please read: https://openfoodfacts.github.io/openfoodfacts-server/api/#authentication

Adding images to support your edit, and get machine learning predictions#

If you ask your users just one thing, it would be to send photos of the packaging (front, ingredients, nutrition, recycling, the more the better)
Please refer to our comprehensive tutorial on uploading images


Sending the right country and language parameters, based on the country your user is located in, and the language the product is in.#

Traditionnaly we advised 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: https://us.openfoodfacts.org/cgi/product_jqm2.pl?​​​​​​​

We now advise to pass the cc and lc parameters within the query, and to limit assumptions as much as you can, especially in bilingual countries (e.g. Belgium, the US…) but also other countries (some products can be imported). Ideally, your UI or some heuristic (traditional or using ML) on your side should determine which language(s) the data you send is in (e.g. for multilingual products, send the French ingredient list as a French ingredient list). We perform OCR on incoming images (even non selected ones), and make the JSON available immediately, so you can either leverage that (you upload the image, and then you select them in a second step, based on the OCR output from the Open Food Facts image server), or use on device ML to determine the proper language to send the call in.

New documentation for cc and lc parameters​​​​​​​

Sample image and sample JSON you can base your heuristic on.


Product Barcode#

After the version number, the word code, followed by its barcode must be added:

https://us.openfoodfacts.org/cgi/product_jqm2.pl?code=0074570036004


Credentials#

Dave adds his user credentials to the call as follows:

https://us.openfoodfacts.org/cgi/product_jqm2.pl?code=0074570036004&user_id=myappname&password=**


Parameters#

You can define one or more parameters to add, for example, the brand and the Kosher label:

  • brands: Häagen-Dazs
  • labels: kosher

The call looks like this:

POST https://us.openfoodfacts.org/cgi/product_jqm2.pl?code=0074570036004&user_id=test&password=test&brands=Häagen-Dazs&labels=kosher

We strongly advise to use add_brands and add_labels instead, even on new products, to reduce the potential of your users or your API destroying data by mistake. brands or labels should be used if and only if you retrieve existing values, show them to your users, let them adjust them, and resend the whole dict with the proper format.


Adding Additional Information to Existing Fields#

To add additional information to existing parameters, add the prefix add_ to the parameter name.

Important! If you don't use the add_ prefix, the existing values will be deleted.

Example

POST https://us.openfoodfacts.org/cgi/product_jqm2.pl?code=0074570036004&user_id=test&password=test&add_categories=Desserts

To see the complete list of parameters, see the Parameters section.


Adding a Comment to your WRITE request.#

Use the comment parameter to add the id of the user editing the product. The id should not contain any personal data.

Important! The user id is not the identifier of an Open Food facts user, but the id generated by your system.

It should be structured as: user-agent + user-id.

Example

comment=Edit by a Healthy Choices 1.2 iOS user - SxGFRZkFwdytsK2NYaDg4MzRVenNvUEI4LzU2a2JWK05LZkFRSWc9PQ


Leveraging Robotoff ML predictions to simplify life for your users#

Leveraging Robotoff prediction to simplify life for your users: https://openfoodfacts.github.io/openfoodfacts-server/api/intro-robotoff/ You can get a category prediction from images (useful for Nutri-Score and Eco-Score), you can get quality labels prediction, brand predictions, weight predictions from images. To achieve this you need the upload image section above. Adding data like product name, ingredients and nutrition can help, but some predictions can be done with just images.

Getting your users to check ingredients OCR in an autonomous fashion#

Getting your users to check ingredients OCR in an autonomous fashion: https://openfoodfacts.github.io/openfoodfacts-server/reference/api-tutorials/get-ingredient-related-analysis/

Getting your users to input nutrition facts#

Getting your users to input nutrition facts: https://openfoodfacts.github.io/openfoodfacts-server/dev/explain-nutrition-data/

Getting your users to input packaging data#

Getting your users to input packaging data: https://openfoodfacts.github.io/openfoodfacts-server/dev/explain-packaging-data/

Showing the result of their work#

  • You can then reload the product, potentially using Knowledge Panels, to show the rewarding result of their work.
  • Make sure to congratulate them each time for their contribution to Open Food Facts and the common good.