Open Food Facts Search API Version 2

From Open Food Facts wiki
Revision as of 11:54, 26 August 2020 by Stephane (talk | contribs) (Created page with "= Open Food Facts Search API Version 2 = == Introduction == The existing Open Food Facts search API is outdated and hacky (it was built on top of the OFF web site search for...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Open Food Facts Search API Version 2

Introduction

The existing Open Food Facts search API is outdated and hacky (it was built on top of the OFF web site search form and is unnecessarily convoluted) and does not support some of the requirements for the Project:Personalized_Search (in particular being able to retrieve a given set of products using their barcodes).

We are thus creating a new Open Food Facts Search API Version 2 that will be simpler but also more powerful.

Features

New /api/v2/search (JSON) and /search (OFF web site) endpoints

The current search API is a hack on the web site search form and is accessed by adding &json=1 to the /cgi/search.pl web form.

The new search API introduces 2 new endpoints that mimick the product page endpoints (/product/[barcode] for the Web, and /api/v0/product/[barcode] for the API with JSON results):

  • /search will replace /cgi/search.pl as the url of search results
  • /api/v2/search will return JSON results, with the exact same parameters as the /search endpoint

Simplified parameters specification

OR tags fields queries

Development and deployment

The new Search API V2 will be developed and deployed incrementally, and it will co-exist with the existing Search API V1. V1 of the API will not be deprecated until V2 covers an extensive all needed search features.

Tags fields

Nutrients

Other fields

e.g. product name