openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
GNU Affero General Public License v3.0
633 stars 371 forks source link

Create a compact version of the product JSON #623

Closed teolemon closed 6 years ago

teolemon commented 7 years ago

We need a compact version of the product JSON to ensure the mobile app works in poor network conditions and in intensive scanning scenario. Same output as https://github.com/openfoodfacts/openfoodfacts-server/issues/554 (name, brand, weight, very small image resolution url) but as a plus, would it be possible to add the nutriscore to the output. We have a new Quick viewmode that lets you lookup many products very quickly in a row, showing the Nutriscores, and the result should be instant.

image

teolemon commented 7 years ago

Also, being able to disable the debug fields in the full view would be nice. Kind of a verbose option.

aleene commented 7 years ago

Seems very dependent on the usage scenario, what you put in such a json. Otherwise seems a good idea. Is there already a demand?

teolemon commented 7 years ago

Product

teolemon commented 7 years ago

@aleene the demand is for the Quick View mode of the official app. We put basic useful info (nutriscore, product name and brand, small image) as well as info useful to trigger contribution (missing images)

vrublack commented 7 years ago

This would also be useful for my website https://www.tacoshell.io

stephanegigandet commented 6 years ago

How about this: we add a new optional fields parameter to the read product API, and if specified, we only return fields specified. That way apps can select what they want and only what they want. Trying to find a common compact subset of fields is always going to be too much or too little for some apps.

e.g.

https://world.openfoodfacts.net/api/v0/product/3700278400881/poudre-instantanee-banania?fields=product_name,categories_tags,ingredients_text,image_front_small_url,nutrition_grades_tags

stephanegigandet commented 6 years ago

We can do the same for the search API:

https://world.openfoodfacts.net/cgi/search.pl?search_terms=nutella&search_simple=1&action=process&json=1&fields=product_name,nutrition_grades_tags

stephanegigandet commented 6 years ago

Also works on facets: https://world.openfoodfacts.net/category/pizzas.json?fields=product_name,categories_tags,ingredients_text,image_front_small_url,nutrition_grades_tags

aleene commented 6 years ago

I like the idea and can be used for other things as well. Reading on jsons however I got the imprssion that it is a bad habit of leaving fields out. Probably will require additional code for the api user to check if fields are there.