Changes

Jump to navigation Jump to search
204 bytes added ,  12:01, 2 February 2017
Line 85: Line 85:  
=== JSON interface ===
 
=== JSON interface ===
 
=== Countries and Language of the Response ===
 
=== Countries and Language of the Response ===
You can either use the global (https://world.openfoodfacts.org) for locales (https://fr,https:// en…)
+
You can either use the global (https://world.openfoodfacts.org, https://ssl-api.openfoodfacts.org) or local (https://fr.openfoodfacts.org,https://en.openfoodfacts.org…) domains for your API queries
   −
A few things to note:
+
====A few things to note====
* if you use a country subdomain instead of world, you get products for that countries only which might change the language but also the name of the fields, in that case you need to use the local language
+
* if you use a country subdomain instead of world, you get products for that country only, which might change the language but also the name of the fields. In that case you need to use the local language.
 
** https://fr.openfoodfacts.org/categorie/pizzas.json
 
** https://fr.openfoodfacts.org/categorie/pizzas.json
** an alternative is to specify the language in the subdomain: https://fr-en.openfoodfacts.org/category/pizzas.json
+
* an alternative to avoid dealing with local languages is to specify the language in the subdomain: https://fr-en.openfoodfacts.org/category/pizzas.json
    +
==== Country code (cc) and Language of the interface (lc) ====
 
By default, the country code (cc) and language of the interface (lc) are set through the subdomain.
 
By default, the country code (cc) and language of the interface (lc) are set through the subdomain.
e.g.
+
===== Examples =====
1.1. https://world.openfoodfacts.org --> cc = world, lc = en (default language for the "country")
+
# https://world.openfoodfacts.org --> cc = world, lc = en (default language for the "country")
1.2 https://fr.openfoodfacts.org --> cc = fr (France), lc = fr (French)
+
# https://fr.openfoodfacts.org --> cc = fr (France), lc = fr (French)
1.3 https://jp.openfoodfacts.org --> cc = jp (Japan), lc = ja (Japanese)
+
# https://jp.openfoodfacts.org --> cc = jp (Japan), lc = ja (Japanese)
1.4 https://ch.openfoodfacts.org --> cc = ch (Switzerland), lc = de (German, set as main language for Switzerland)
+
# https://ch.openfoodfacts.org --> cc = ch (Switzerland), lc = de (German, set as main language for Switzerland)
1.5 https://ch-fr.openfoodfacts.org --> cc = ch, lc = fr (French)
+
# https://ch-fr.openfoodfacts.org --> cc = ch, lc = fr (French)
 
   
==== Over-riding country code and interface language using cc and lc parameters ====
 
==== Over-riding country code and interface language using cc and lc parameters ====
   
If you pass ?cc=us and/or &lc=it, it will set the country to US and the language to Italian
 
If you pass ?cc=us and/or &lc=it, it will set the country to US and the language to Italian
   
-> if you just pass cc, the lc will be the one set in the subdomain.
 
-> if you just pass cc, the lc will be the one set in the subdomain.
 
e.g. world.openfoodfacts.org + cc = fr --> cc = fr, lc = en (default language of world)
 
e.g. world.openfoodfacts.org + cc = fr --> cc = fr, lc = en (default language of world)

Navigation menu