Open Food Facts

Open Food Facts

Public API Docs - Open Food Facts

Open Food Facts is a collaborative, free and open database of food products from around the world. The API provides programmatic access to the data available on the Open Food Facts project, in order to build applications, or books that make use of this data.

API Endpoints

The available endpoints for querying Open Food Facts are:

  • /api/v0/product/[barcode].json: Returns the product data in JSON format for the given barcode
  • /api/v0/product/[barcode].html: Returns the HTML page for the given barcode
  • /cgi/ Allows to search for products by different parameters, including category, brand, country and more.

Example Code

Here’s an example in JavaScript (node.js) that fetches the product information for a given barcode:

const https = require('https');

let barcode = '3263859125';

        '' +
            barcode +
        (resp) => {
            let data = '';

            // A chunk of data has been received.
            resp.on('data', (chunk) => {
                data += chunk;

            // The whole response has been received.
            resp.on('end', () => {
    .on('error', (err) => {
        console.log('Error: ' + err.message);

This code retrieves the product data in JSON format for the barcode 3263859125. To query other barcodes, just change the value of the barcode variable.

Open Food Facts is a very useful resource for anyone interested in the nutritional value of food products, or in building applications around food data.