Changes

Jump to navigation Jump to search
1,602 bytes added ,  07:13, 8 September 2020
Line 52: Line 52:  
=== Request ===
 
=== Request ===
   −
Apps can request Product Attributes through API queries (/product or /search) by including "attributes_[language code]" (or "attributes_data" to get only the machine readable data) in the "fields" parameter.
+
Apps can request Product Attributes through API queries (/product or /search) by including "attribute_groups" or "attribute_groups_[language code]" (or "attribute_groups_data" to get only the machine readable data) in the "fields" parameter.
    
=== Response ===
 
=== Response ===
   −
For each product returned, a new "attributes_[language code]" or "attributes_data" field is added, containing an array of sections (to regroupe attributes, like all allergens) that each contain an array of attributes.
+
For each product returned, the corresponding field is added, containing an array of groups (to regroup attributes, like all allergens) that each contain an array of attributes.
   −
==== Section format ====
+
==== Attribute group format ====
    
* id - e.g. nutritional_quality
 
* id - e.g. nutritional_quality
Line 81: Line 81:  
* off_link_title
 
* off_link_title
 
* off_link_url
 
* off_link_url
 +
 +
==== Example ====
 +
 +
* Request: https://world.openfoodfacts.org/api/v0/product/3700214614266?fields=product_name,code,attribute_groups_en
 +
* Response:
 +
 +
<pre>
 +
{
 +
status: 1,
 +
code: "3700214614266",
 +
status_verbose: "product found",
 +
product: {
 +
product_name: "Chocolat noir Pérou 90% fruité et boisé",
 +
code: "3700214614266",
 +
attribute_groups_en: [
 +
{
 +
attributes: [
 +
{
 +
status: "known",
 +
name: "Nutri-Score",
 +
match: 30,
 +
id: "nutriscore",
 +
title: "Nutri-Score D",
 +
description: "",
 +
description_short: "Poor nutritional quality"
 +
}
 +
],
 +
name: "Nutritional quality",
 +
id: "nutritional_quality"
 +
},
 +
{
 +
id: "processing",
 +
name: "Food processing",
 +
attributes: [
 +
{
 +
id: "nova",
 +
match: 50,
 +
name: "NOVA group",
 +
status: "known",
 +
description_short: "Processed foods",
 +
description: "",
 +
title: "NOVA 3"
 +
}
 +
]
 +
},
 +
{
 +
id: "labels",
 +
name: "Labels",
 +
attributes: [
 +
{
 +
title: "Organic product",
 +
description_short: "Promotes ecological sustainability and biodiversity.",
 +
description: "Organic farming aims to protect the environment and to conserve biodiversity by prohibiting or limiting the use of synthetic fertilizers, pesticides and food additives.",
 +
name: "Organic farming",
 +
match: 100,
 +
status: "known",
 +
id: "labels_organic"
 +
},
 +
{
 +
id: "labels_fair_trade",
 +
match: 100,
 +
name: "Fair trade",
 +
status: "known",
 +
description_short: "Fair trade products help producers in developping countries.",
 +
description: "When you buy fair trade products, producers in developing countries are paid an higher and fairer price, which helps them improve and sustain higher social and often environmental standards.",
 +
title: "Fair trade product"
 +
}
 +
]
 +
}
 +
]
 +
}
 +
}
 +
</pre>
    
== Example uses ==
 
== Example uses ==

Navigation menu