Skip to content

Comparing sodas

Dave wants his app to make an API call to provide Anna the information she needs to make a conscious choice when buying sodas.

Authentication and Header#

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:

API Version#

The current version number of the Open Food Facts API is v0.

Product Barcode#

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

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: