Part of Losing Weight to achieve My Personal Health Goals, I went to several resources on the internet to get calories and nutritional information, including Omega-3 and Omega-6 quantiies for differerent foods. I had used MyFitnessPal in the past, but I didn't really like their interface, so of course I went looking. What I found was FoodData Central.
When Compared to Some Sites - Other Site's Data Was Wrong
Looking for a source to get my nutritional info, I found the United States Department of Agriculture (USDA) website called FoodDate Central. This website contains detailed nutritional information - all that I wanted to see to help me calculate my Omega-3 to Omega-6 ratio (hopefully coming in less than 1:4). Once I was there I had a GREAT DESIRE to have this data in my own hands, possibly on my own website.... So my journey began.
https://fdc.nal.usda.gov/fdc-app.html#/
Many Many Choices
In this example search below, I looked for ony of my new favorite foods (or drinks...) for Kefir. There were 2 SR Legacy Foods, One Survey Foods (FNDDS) and 423 Branded Foods. I just want to get the nutritional info for Lifeway Kefir, but they have tested over 425 kefir products that they include in this database. Think of how many products they have testesd - so many!
https://fdc.nal.usda.gov/fdc-app.html#/
Lots and Lots of Data
The website had all the nutritional information I was looking for, and some that I didn't even know existed. What a
different world from my career in business and engineering.
https://fdc.nal.usda.gov/fdc-app.html#/food-details/170904/nutrients
Strategies to Get the Data
Now that I knew of a possible location to retrieve the data, how do I get it into my system? I like this dataset because it is probably very accurate, since the US Government really has no reason to make it anything but accurate. It is also free, and freely distributable.
https://fdc.nal.usda.gov/download-datasets.html
It's Complicated.....
Now that I found I could download the data, how on earth do I process it for just the foods that I want to include? Yikes, that is a lot of data and a lot of decisions on what to do with it.
https://fdc.nal.usda.gov/download-datasets.html
Excel Files
I know a lot about Excel files, so I downloaded the .csv files, and they were VERY COMPLICATED. I also clicked the API Guide, and signed up for an API Key. Now somehow I can get the Government Data somehow with my magic key (API Key).
https://fdc.nal.usda.gov/index.html
FDC API
The good news is that I was able to get the API Key working pretty quickly after about 4 hours of research. Then I find the results are in this crazy looking thing.
ChatGPT to the Rescue!
Well, I am a bit smarter these days, so I just asked my friend ChatGPT how to do it, and WOW - she took care of me so fast!.... Writing code and all is so much faster now, as I only edit the code a little bit. No more finger cramps for me.
Visual Studio 2022
After a little bit of time later (probably and hour or two later...) I had working code with my Visual Studio 2022 program called JSONTutorial. Now that I can do the whole process of getting the Response back from an API Query, pop it in a text file, then parse it with my JSON Parser in Visual Studio 2022, I can do what I want with it. Now to decide how to figure out which foods I want to do this all for.... That might be harder than what I have already had to go through..... all to get my Omega-3 to Omega-6 ratios correct..... Yep, I am a strange duck!
Python Program
This program will retrieve information using Python, accessing the usda.gov website and generating a query using my API Key. This is probably how I will create the dataset that I want, then I will parse it with Visual Studio 2022 and pop it wherever I am going to put all this stuff.
So What Is JSON?
Here is a little tutorial that I spent just a couple of minute looking at before I asked ChatGPT for some help. If you want to learn JSON, I would go here.
https://www.w3schools.com/js/js_json_intro.asp