Jump to content

Open Food Facts Search API Version 2: Difference between revisions

ā†’ā€ŽFeatures: add links to API to demonstrate the features
(ā†’ā€ŽFeatures: add links to API to demonstrate the features)
Line 34: Line 34:


Tags fields are now specified directly:
Tags fields are now specified directly:
* labels_tags=en:organic
* [https://world.openfoodfacts.org/api/v2/search?labels_tags=en:organic&fields=code,product_name,labels_tags labels_tags=en:organic]
* labels_tags_fr=bio -> bio is assumed to be in French and thus converted to en:organic
* [[https://world.openfoodfacts.org/api/v2/search?labels_tags_fr=bio&fields=code,product_name,labels_tags_en labels_tags_fr=bio -> bio is assumed to be in French and thus converted to en:organic


For AND queries, use comma separated values:
For AND queries, use comma separated values:


* labels_tags=en:organic,en:fair-trade
* [https://world.openfoodfacts.org/api/v2/search?labels_tags=en:organic,en:fair-trade&fields=code,product_name,labels_tagsĀ  labels_tags=en:organic,en:fair-trade]


For negative queries, prefix tag with -
For negative queries, prefix tag with -
* labels_tags=-en:organic,-en:fair-trade
* [https://world.openfoodfacts.org/api/v2/search?labels_tags=en:organic,-en:fair-trade&fields=code,product_name,labels_tagsĀ  labels_tags=-en:organic,-en:fair-trade]


=== OR tags fields queries ===
=== OR tags fields queries ===


For OR queries, use | to separate values
For OR queries, use | to separate values
* labels_tags=en:organic|en:fair-trade|en:some-other-label
* [https://world.openfoodfacts.org/api/v2/search?labels_tags=en:organic|en:fair-trade|en:some-other-label&fields=code,product_name,labels_tags labels_tags=en:organic|en:fair-trade|en:some-other-label]


=== Conditions on nutrients ===
=== Conditions on nutrients ===