openfoodfacts / openfoodfacts-dart

Open Food Facts API Wrapper
https://pub.dev/packages/openfoodfacts
Apache License 2.0
161 stars 65 forks source link

Add the Eco-Score by country API #190

Open teolemon opened 3 years ago

teolemon commented 3 years ago

What

Add this chunk of documentation as a comment

You need to ensure the country your users are in:

- Asking them explicitly at startup, and storing the value
- Geofencing your app to just one country
- Using the phones or the IP address (using eg GeoIP) to infer a country

You need to serve the matching Eco-Score value
You can ask for a country specific Eco-Score
If your users are outside France, you need to clearly display the experimental disclaimer at least once.

Potential block

monsieurtanuki commented 2 years ago

This is more or less what I've understood:

I guess this issue should be fixed rather on the backend every time there's a query about a ProductField.ECOSCORE_... field:

Am I missing something?

teolemon commented 2 years ago
monsieurtanuki commented 2 years ago

@teolemon I still cannot picture the whole thing.

For instance, let's start from https://world.openfoodfacts.org/api/v0/product/8076809572569.json?fields=nutriscore_score,nutriscore_grade,ecoscore_score,ecoscore_grade

  1. in this case, whose country are those grades computed for?
  2. I got the same result ({"ecoscore_grade":"d","ecoscore_score":39,"nutriscore_grade":"d","nutriscore_score":17}) after replacing world. with fr., es., it., be., de. and nl. - am I just unlucky or is the URL wrong? Btw same result with pt., which is not in the OP country list.
  3. If I try to replace the field names like ecoscore_grade_nl, there's not matching output for this particular field

In short, it looks like we have nutriscore and ecoscore fields computed only one way, with no way to specify a country.