GnistAI GnistAI
Log in

Getting Started with Open Food Facts

Food product database — barcode lookup, nutrition facts, Nutri-Score, ingredients.

All Tutorials   |   Overview   |   Playground   |   MCP   |   REST API   |   Home
Food & Drink

Data source: Open Food Facts (community database)

Overview

Open Food Facts wraps Open Food Facts (community database), handling authentication, pagination, and rate limits for you. This tutorial covers all 3 tools with working code examples you can copy and run.

Prerequisites

  1. Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
  2. Choose your integration method: MCP protocol or REST API.

Connect via MCP

Add to your MCP client config (Claude Desktop, Cursor, etc.):

MCP Config
{
  "mcpServers": {
    "gnist-openfoodfacts": {
      "url": "https://context.gnist.ai/mcp/openfoodfacts/",
      "headers": {
        "Gnist-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Tools (3)

get_food_product

Look up a food product by barcode (EAN-13 or UPC-A). Returns product name, brand, Nutri-Score, NOVA group, ingredients, and full nutrition facts per 100g. Args: barcode: Product barcode (e.g. "3017620422003" for Nutella).

ParameterTypeRequiredDescription
barcodestringrequired
curl -X POST "https://context.gnist.ai/mcp/openfoodfacts/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_food_product", "arguments": {"barcode": "example"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/openfoodfacts/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'barcode': 'example'}, 'name': 'get_food_product'}},
)
print(resp.json())

search_food_products

Search the Open Food Facts database for food products by name. Returns matching products with barcode, name, brand, and Nutri-Score. Args: query: Product name search (e.g. "nutella", "oat milk", "granola"). limit: Maximum number of results (1-50, default 10).

ParameterTypeRequiredDescription
querystringrequired
limitintegeroptional (default: 10)
curl -X POST "https://context.gnist.ai/mcp/openfoodfacts/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_food_products", "arguments": {"query": "renewable energy"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/openfoodfacts/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'query': 'renewable energy'},
            'name': 'search_food_products'}},
)
print(resp.json())

report_feedback

Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.

ParameterTypeRequiredDescription
feedbackstringrequired
feedback_typestringoptional (default: general)
curl -X POST "https://context.gnist.ai/mcp/openfoodfacts/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/openfoodfacts/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())

Common Patterns

Search then retrieve
Use search_food_products to find items, then get_food_product to get full details. This two-step pattern is common for exploring data before drilling down.
Pagination
Several tools support limit, offset, or page parameters. Start with small limits during development, then increase for production queries.

FAQ

What data does Open Food Facts provide?

Food product database — barcode lookup, nutrition facts, Nutri-Score, ingredients. It exposes 3 tools: get_food_product, search_food_products, report_feedback.

What do I need to get started?

A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.

What format does the Open Food Facts API return?

JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.

Next Steps

Related Tutorials