Get Nutrition Facts From Barcode in Google Sheets

Learn how to extract nutrition facts from barcodes using the Open Food Facts API in Google Sheets. This tutorial covers setting up API calls and creating custom functions for seamless data retrieval.

Let's get some food facts. Here we have some barcodes and we want to use open food facts. They have an API and we want to get some information into our sheet.

We can put in a barcode here and we can give some queries like we can say hey this is actually food in beauty food pet food or product or all we can say the US code letter code we can put in um English or whatever language it is.

So what it's saying is curl get we're getting this URL everything within this um uh string is the URL that we're going to go to and then we have a header and it says application JSON.

We do need maybe this header is it's always going to be application JSON, but I will show you where to put that actually right now.

Let's make this a custom function. slash atcustom function. Save this. Then go into our sheet equals get open.

Let's code this a little bit. Let's use chatd. Let's just ask it to check the name of the product.

It says still kept our custom function get openfoodfacts. Perfect parameters.

So this is a much better version, much simpler. Let's see that. So it's just going to this URL with the barcode, very simple URL, getting the response.

So we'll use function on E and this is like an event variable.

We are going to end up with spreadsheet app get active spreadsheet getactive sheet.get range row and column two set value.

We can change this function to do this on edit. Save it and run it with a trigger.

So now we will only grab data if there is a part. So if we delete something, this should not be deleted.

You're watching Better Sheets here on YouTube. Make sure you check out this video or this video and subscribe right now.