Line 1: |
Line 1: |
| + | [[Category:ProductOpener]] [[Category:API]] |
| == Summary == | | == Summary == |
| | | |
Line 46: |
Line 47: |
| * <code>{nutrient-id}_(100g|serving)</code>: is set to <code>{nutrient-id}</code> (e.g. if <code>nutrition_data_per = 100g</code>, the value of <code>sugars_100g</code> is set to the value of sugars. | | * <code>{nutrient-id}_(100g|serving)</code>: is set to <code>{nutrient-id}</code> (e.g. if <code>nutrition_data_per = 100g</code>, the value of <code>sugars_100g</code> is set to the value of sugars. |
| * If the serving size is known, we compute the value for the other field (nutrient-id_100g or nutrient-id_serving) in default unit. | | * If the serving size is known, we compute the value for the other field (nutrient-id_100g or nutrient-id_serving) in default unit. |
| + | * The value of <code>energy_(100g|serving)</code> is calculated from <code>energy-kJ_(100g|serving)</code> if available, otherwise it is calculated from <code>energy-kcal}_(100g|serving)</code>. This field is in <code>kJ</code>. Note however that the kJ and kcal can be different according to the regulation, so do not assume a factor of 4.2 between the values. |
| | | |
| === Data display === | | === Data display === |
Line 51: |
Line 53: |
| The OFF web site, and apps, '''should only use these OFF processed fields''' to display the nutrition data: | | The OFF web site, and apps, '''should only use these OFF processed fields''' to display the nutrition data: |
| | | |
− | * <code>{nutrient-id}_100g</code> or <code>{nutrient-id}_serving</code> (depending on the value of nutrition_data_per): value in g or in kJ. The values are passed as float/double??? | + | * <code>{nutrient-id}_100g</code> or <code>{nutrient-id}_serving</code> (depending on the value of the value of <code>nutrition_data_per</code>): value in g or in kJ. The values are passed as float/double??? |
− | * <code>{nutrient-id}_value</code>: to show the original entered/passed data (useful for characters as "<" or "~"). | + | * <code>{nutrient-id}_modifier</code> to get the value modifier ("<", ">", "~") |
| + | * <code>{nutrient-id}_value</code>: to show the original entered/passed data. |
| | | |
| The web site and apps '''must''': | | The web site and apps '''must''': |
Line 71: |
Line 74: |
| == Possible improvements to make things (a bit) simpler == | | == Possible improvements to make things (a bit) simpler == |
| | | |
− | * In the API, rename the "nutrient-id" fields (such as energy-kj, saturated-fat) to "nutrient-id_value", so that it matches the name of the field stored. It also makes clearer where the value is coded. | + | * In the API, rename the <code>{nutrient-id}</code> fields (such as <code>energy-kj</code>, <code>saturated-fat</code>) to <code>{nutrient-id}_value</code>, so that it matches the name of the field stored. It also makes clearer where the value is coded. |
− | * Store the energy-kcal values in kcal, without converting them to kJ | + | * Store the <code>energy-kcal</code> values in kcal, without converting them to kJ |
| ** This is probably what people intuitively expect | | ** This is probably what people intuitively expect |
| ** It removes unnecessary conversions from kcal to kJ and back (which is not trivial, as some people/apps may choose a different conversion factor, such as 4.2 or 4.185) | | ** It removes unnecessary conversions from kcal to kJ and back (which is not trivial, as some people/apps may choose a different conversion factor, such as 4.2 or 4.185) |
| ** This would be a breaking change if some apps use the energy-kcal_100g/serving or energy-kj_100g/serving fields | | ** This would be a breaking change if some apps use the energy-kcal_100g/serving or energy-kj_100g/serving fields |
| + | * Expose only the recommended fields (see [[Nutrients_handling_in_Open_Food_Facts#Data_display|data display]]) |
| | | |
| == Possible improvements to make things (a bit) more complex == | | == Possible improvements to make things (a bit) more complex == |
Line 86: |
Line 90: |
| | | |
| e.g. saturated-fat_prepared_100g, saturated-fat_prepared_value etc. | | e.g. saturated-fat_prepared_100g, saturated-fat_prepared_value etc. |
| + | == Documentation == |
| + | * [https://blog.trustwell.com/calorie-calculation-country How calories are calculated in different countries]. |
| + | * [https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32011R1169&from=FR%20Appendix%20XIV#d1e32-62-1 Energy calculation in the EU] |