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.
- 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
Install using the Node-RED palette manager or via npm:
npm install node-red-contrib-open-food-facts
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
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
Access categorized data (additives, allergens, brands, etc.).
Inputs:
-
msg.payload
: Taxonomy type (e.g., "additives", "allergens", "brands")
Outputs:
-
msg.payload
: Taxonomy data object
Add a new product to the OpenFoodFacts database (requires authentication).
Configuration:
- Username and password credentials required
Inputs:
-
msg.payload
: Product data object withcode
,brands
(optional),labels
(optional)
Outputs:
-
msg.payload
: API response
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 withfield
(front/ingredients/nutrition) andlanguageCode
-
Outputs:
-
msg.payload
: API response
Retrieve the additives taxonomy.
Outputs:
-
msg.payload
: Additives taxonomy data
Retrieve the allergens taxonomy.
Outputs:
-
msg.payload
: Allergens taxonomy data
Retrieve the brands taxonomy.
Outputs:
-
msg.payload
: Brands taxonomy data
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
[
{
"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": []
}
]
[
{
"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": []
}
]
{
"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
}
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) |
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
Run the test suite:
npm test
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
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.
Contributions are welcome! Please see our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
This node uses the Open Food Facts API. Open Food Facts is a collaborative project with contributors from around the world.
- For issues and feature requests, please use the GitHub issue tracker
- For questions about the Open Food Facts API, visit their documentation
- Open Food Facts team for maintaining the amazing food products database
- Node-RED community for the excellent IoT platform