Changes

Jump to navigation Jump to search
Adding examples of V2 of the API, clarification of the ongoing support for V1
Line 3: Line 3:  
== Introduction ==
 
== 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).
+
Version 1 of the 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.
+
We have thus created a new Open Food Facts Search API Version 2 that is simpler but also more powerful.
 +
 
 +
* Version 1 of the API will continue to be supported for the years to come, as there are many apps that are using it.
 +
* Version 2 of the API was launched in production in September 2020. It has not been widely publicized yet as we may change it based on the feedback of the first users.
 +
 
 +
== Examples ==
 +
 
 +
Products from the chocolate category, with both the organic label and the fair trade label:
 +
 
 +
* V1:
 +
* V2: https://world.openfoodfacts.org/api/v2/search?categories_tags_en=chocolates&labels_tags_en=organic,fair%20trade&fields=code,product_name
    
== Features ==
 
== Features ==
Line 11: Line 21:  
=== New /api/v2/search (JSON) and /search (OFF web site) endpoints ===
 
=== 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.
+
V1 of the 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):
 
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):
Line 47: Line 57:  
== Development and deployment ==
 
== 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.
+
The new Search API V2 has been be developed and deployed incrementally, and it co-exists with the existing Search API V1.
 +
 
 +
V1 of the API will be supported for the years to come as many apps are using it.
    
=== Tags fields ===
 
=== Tags fields ===
   −
* [https://github.com/openfoodfacts/openfoodfacts-server/issues/4011 New search API - tags fields #4011]
+
* [https://github.com/openfoodfacts/openfoodfacts-server/issues/4011 New search API - tags fields #4011] - done
    
=== Nutrients ===
 
=== Nutrients ===
   −
* [https://github.com/openfoodfacts/openfoodfacts-server/issues/4075 New search API - conditions on nutrients #4075]
+
* [https://github.com/openfoodfacts/openfoodfacts-server/issues/4075 New search API - conditions on nutrients #4075] - done
 
  −
=== Other fields ===
  −
 
  −
e.g. product name
         
[[Category:Project:Personalized_Search]]
 
[[Category:Project:Personalized_Search]]
 
[[Category:ProductOpener]]
 
[[Category:ProductOpener]]

Navigation menu