How to create nutrition app with ocr scanner?

Looking pretty good so far!

You’ll want to use the barcode scanner’s “value” block in your Web API Get call. Do this by assigning a variable to the green “value” block. Then, join the new variable to the URL text.

According to this page, the format for the barcode url is:

https://world.openfoodfacts.org/api/v0/product/[barcode].json

So you can join “https://world.openfoodfacts.org/api/v0/product/” with the new variable and then with “.json”

Just out of curiosity, I tried this with a product I have: https://world.openfoodfacts.org/api/v0/product/856904000376.json.

When I put the results in the JSON formatter page, I get this:

If, for example, you wanted to get the “nutrition_data_per” field (value of 100g), you would take the “nutrition_data_per” property of the “product” property of the object. That’s working my way back up from that field in the formatted list of properties.

1 Like