Open Food Facts API
world.openfoodfacts.org · Food
Open database of food products worldwide — 3.3M+ products with ingredients, nutritional facts, additives, labels, and allergens. Search by barcode or text. No API key required.
Authentication
No authentication requiredFree to use with no key needed.
Sample Requests
GET
Get product by barcode
Get Nutella product data by barcode.
https://world.openfoodfacts.org/api/v2/product/3017624010701.json
Hover any highlighted part to learn what it does
curl -X GET "https://world.openfoodfacts.org/api/v2/product/3017624010701.json"
import requests
response = requests.get(
"https://world.openfoodfacts.org/api/v2/product/3017624010701.json",
)
print(response.json())const url = 'https://world.openfoodfacts.org/api/v2/product/3017624010701.json'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://world.openfoodfacts.org/api/v2/product/3017624010701.json"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://world.openfoodfacts.org/api/v2/product/3017624010701.json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://world.openfoodfacts.org/api/v2/product/3017624010701.json";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Search products
Search products by name.
https://world.openfoodfacts.org/cgi/search.pl?json=1&action=process&page_size=5&search_terms=chocolate&search_simple=1
Hover any highlighted part to learn what it does
curl -X GET "https://world.openfoodfacts.org/cgi/search.pl?json=1&action=process&page_size=5&search_terms=chocolate&search_simple=1"
import requests
params = {
"json": "1",
"action": "process",
"page_size": "5",
"search_terms": "chocolate",
"search_simple": "1"
}
response = requests.get(
"https://world.openfoodfacts.org/cgi/search.pl",
params=params,
)
print(response.json())const url = new URL('https://world.openfoodfacts.org/cgi/search.pl');
url.searchParams.set('json', '1');
url.searchParams.set('action', 'process');
url.searchParams.set('page_size', '5');
url.searchParams.set('search_terms', 'chocolate');
url.searchParams.set('search_simple', '1');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://world.openfoodfacts.org/cgi/search.pl")
q := baseURL.Query()
q.Set("json", "1")
q.Set("action", "process")
q.Set("page_size", "5")
q.Set("search_terms", "chocolate")
q.Set("search_simple", "1")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://world.openfoodfacts.org/cgi/search.pl")
uri.query = URI.encode_www_form({
"json" => "1",
"action" => "process",
"page_size" => "5",
"search_terms" => "chocolate",
"search_simple" => "1"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://world.openfoodfacts.org/cgi/search.pl?" . http_build_query([
"json" => "1",
"action" => "process",
"page_size" => "5",
"search_terms" => "chocolate",
"search_simple" => "1"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- No API key needed
- Barcode lookup: GET https://world.openfoodfacts.org/api/v2/product/{barcode}.json
- Try barcode 3017624010701 (Nutella) or 5449000000996 (Coca-Cola)
- Search: GET /cgi/search.pl?search_terms=organic+milk&json=1&page_size=5