npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-red-contrib-open-food-facts

v0.3.1

Published

A Node-RED node that provides easy integration with the Open Food Facts API. Search for products, retrieve product information, add products, and manage product images.

Readme

Node-RED Open Food Facts

License: MIT Node.js CI npm version

A Node-RED integration for the Open Food Facts API, providing easy access to food product information, nutrition facts, and ingredient details from the world's largest open food database.

Features

  • Product Lookup: Retrieve detailed product information by barcode
  • Product Search: Search for products using various criteria (name, brand, category, etc.)
  • Taxonomy Access: Access categorized data for additives, allergens, brands, and more
  • Product Management: Add new products and upload product photos (requires authentication)
  • Insights Access: Get random insights from Robotoff for product improvement
  • Asynchronous Operations: All API calls are non-blocking
  • Error Handling: Comprehensive error handling with custom error types
  • Type Safety: Built with modern JavaScript features

Installation

Install using the Node-RED palette manager or via npm:

npm install node-red-contrib-open-food-facts

Nodes

Basic Nodes

OpenFoodFacts Get Product

Retrieve product information by barcode.

Inputs:

  • msg.payload: Barcode string (if not configured in node)

Outputs:

  • msg.payload: Product object with details like name, brand, ingredients, nutrition facts

OpenFoodFacts Search Products

Search for products using various filters.

Inputs:

  • msg.payload: Search parameters object

Example search parameters:

{
  "search_terms": "chocolate",
  "brands": "Nestle",
  "categories": "snacks",
  "page": 1,
  "pageSize": 20
}

Outputs:

  • msg.payload: Search results including count, page information, and products array

OpenFoodFacts Get Taxonomy

Access categorized data (additives, allergens, brands, etc.).

Inputs:

  • msg.payload: Taxonomy type (e.g., "additives", "allergens", "brands")

Outputs:

  • msg.payload: Taxonomy data object

Extended Nodes

OpenFoodFacts Add Product

Add a new product to the OpenFoodFacts database (requires authentication).

Configuration:

  • Username and password credentials required

Inputs:

  • msg.payload: Product data object with code, brands (optional), labels (optional)

Outputs:

  • msg.payload: API response

OpenFoodFacts Upload Photo

Upload a photo for a product (requires authentication).

Configuration:

  • Username and password credentials required

Inputs:

  • msg.payload: Object containing:
    • barcode: Product barcode
    • image: Image file
    • type: Object with field (front/ingredients/nutrition) and languageCode

Outputs:

  • msg.payload: API response

OpenFoodFacts Get Additives

Retrieve the additives taxonomy.

Outputs:

  • msg.payload: Additives taxonomy data

OpenFoodFacts Get Allergens

Retrieve the allergens taxonomy.

Outputs:

  • msg.payload: Allergens taxonomy data

OpenFoodFacts Get Brands

Retrieve the brands taxonomy.

Outputs:

  • msg.payload: Brands taxonomy data

OpenFoodFacts Get Random Insight

Get random insights from OpenFoodFacts Robotoff.

Configuration:

  • count: Number of insights to retrieve (default: 1)
  • lang: Language code for filtering (optional)

Outputs:

  • msg.payload: Random insights from Robotoff

Example Flows

Basic Product Lookup

[
    {
        "id": "inject-barcode",
        "type": "inject",
        "payload": "3017620422003",
        "payloadType": "str",
        "topic": "",
        "name": "Inject Barcode",
        "wires": [["get-product"]]
    },
    {
        "id": "get-product",
        "type": "openfoodfacts-get-product",
        "name": "",
        "wires": [["debug"]]
    },
    {
        "id": "debug",
        "type": "debug",
        "name": "",
        "active": true,
        "wires": []
    }
]

Search by Category

[
    {
        "id": "search-inject",
        "type": "inject",
        "payload": "{\"categories\": \"beverages\", \"page\": 1}",
        "payloadType": "json",
        "topic": "",
        "name": "Search Beverages",
        "wires": [["search-products"]]
    },
    {
        "id": "search-products",
        "type": "openfoodfacts-search-products",
        "name": "",
        "wires": [["debug"]]
    },
    {
        "id": "debug",
        "type": "debug",
        "name": "",
        "active": true,
        "wires": []
    }
]

API Reference

Product Object Structure

{
  "code": "3017620422003",
  "product_name": "Nutella",
  "brands": "Ferrero",
  "categories": "Spreads, Sweet spreads, Chocolate spreads",
  "ingredients_text": "Sugar, Palm oil, Hazelnuts...",
  "nutriments": {
    "energy_100g": 2252,
    "fat_100g": 30.9,
    "carbohydrates_100g": 57.5,
    "proteins_100g": 6.3
  },
  // ... more fields
}

Search Parameters

| Parameter | Type | Description | |-----------|------|-------------| | search_terms | string | General search query | | brands | string | Filter by brand | | categories | string | Filter by category | | code | string | Filter by barcode | | countries | string | Filter by country | | page | number | Page number (default: 1) | | pageSize | number | Results per page (default: 20) |

Error Handling

The nodes emit errors that can be caught using a catch node. Common errors include:

  • Product not found
  • Invalid barcode format
  • Network connectivity issues
  • API rate limiting

Testing

Run the test suite:

npm test

Automated PR Reviews

This repository uses automated PR reviews powered by Amazon Bedrock and Claude AI via GitHub Actions. When you create a pull request, the workflow will automatically:

  • Analyze your code changes
  • Provide intelligent feedback and suggestions
  • Check for potential issues and improvements

Setup Requirements

To enable automated PR reviews, repository administrators need to configure the following secrets in Settings → Secrets and variables → Actions → Repository secrets:

  • AWS_ACCESS_KEY_ID: Your AWS access key with Bedrock permissions
  • AWS_SECRET_ACCESS_KEY: Your AWS secret access key

The workflow uses Claude 3 Haiku via Amazon Bedrock for fast, intelligent code analysis and provides comprehensive reviews including performance and security feedback.

Contributing

Contributions are welcome! Please see our Contributing Guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

This node uses the Open Food Facts API. Open Food Facts is a collaborative project with contributors from around the world.

Support

Acknowledgments

  • Open Food Facts team for maintaining the amazing food products database
  • Node-RED community for the excellent IoT platform