An Application Programming Interface, an API, is fundamental to the development of software and hardware applications. Developers use APIs to access a myriad of databases and application software modules. A developer will integrate any number of databases and software modules with a front-end (Graphical User Interface).tp create an application, better known as an app.
The USDA Food Central Nutrition Database and API
Today developers have tens of thousands of APIs to design with and choose from. After deciding on an applications function, the developer must decide on which database the app will have to communicate with (that is retrieve data from and send data to). Next, the developer will have to decide on which software modules (often accessible via a separate API) to use to give the app its needed functionality.
Most database APIs operate the same and use a REST interface and a JSON data format to communicate with the database. However the data, fields and record structure in databases vary considerably. For example, a nutrition database, like Food Data Central’s database, accessible through the United States Department of Agriculture’s (ISDA’s) web site, contains millions of records and hundreds of data fields.
If a developer wants to create an app based on Food Data Central’s ever-expanding nutritional data, the developer will have to get an authorization key from USDA Food Central’s web site to access the database. Next the developer will have to become familiar with the Food Central API, That API is based on a standard REST and supports the use of cURL to access the database. This makes querying the database relatively straightforward. Becoming familiar with just a few commands will give you the ability to access the Food Central Database.
Still though, the devil is in the details. If you were creating a nutrition app based on the USDA’s nutrition data, you will have to decide on which food database you want to access and which fields you want to query. However, you can keep it simple. Instead of first going through the Food Centrals’ database field classification documents, you can instead search the USDA database on their website, With their easy to use search box you can get a good idea of the field structure and what fields are available.
Below is a screenshot of the mineral content for a potato nutrient search from Food Central. Don’t let the simplicity fool you. The actual results for one 100 gram serving of potatoes contains scores of records and fields. However, just the mineral field is quite helpful. An apps developer could create an app with that data to calculate the RDA percentage for each mineral one receives from a 100 grams of potatoes. All potatoes are however not created equal. The mineral content is for an average from potato samples. The amount of iron can vary in a potato depending on where its grown.
Health care professionals, like nutritionists, and those that are trying to optimize their and their children’s health are naturally interested in this type of nutrition data. Turning this data into an app that is easy to use for the average consumer or even children is the next step. Ideally, one could enter in a list of what they consumed in a day, and the app would in turn provide a selection of food and recipes needed to keep nutrition levels optimum. This would require the developer to retrieve the above data, and use data input from the food consumer (food consumed, age, height, weight, sex, activity level and preconditions) and then The app developer could search for an API that contains a nutrition software module that does that, but odds are it might be difficult to find. Here, the app developer might decide that the best route would be to write their own code to make the nutrition calculations for an individual. The code needed is not that complicated, but does involve some basic math. It could be written on the client side in JavaScript or on the server side in Python or PHP.
The developer will also have to create a form where the consumer would enter in their personal data and the list of foods they consumed. That could be done with HTML. Either way, data would have to retrieved from Food Central and the consumer (client) using the app.
Below is a sample of a nutrition form that would have to be created on the developer’s web site for the app. Its also from the USDA. It asks for sex, age, height, weight etc.
The USDA Nutrition Calculator for Healthcare Professionals
In some part, the USDA has done a portion of that work. Its Daily Reference Intake (DRI) Calculator for Healthcare Professionals, requires that one enter in their age, sex, height and weight and from that data calculates your daily nutritional requirements. The snapshot below shows the daily mineral requirements for a 5’2″ 100 pound, 30-year old woman produced from the DRI calculator.
Conclusion
For the most part, the USDA has the data one would need to create very advanced nutritional apps for the consumer, nutritionists and healthcare professionals. The steps to create an app from their database and API and for the part any database or any API are the same. Obtain the authorization key to the database, determine what fields in the database that need to be accessed, what queries you will have to write, and then what calculations you will have to make using the data returned from the database. As well, the developer will also have to create a user interface (form) that the consumer, nutritionist, or health care provider would use to enter the needed personal data. For a more advanced and automated nutrition app, the app would retrieve the food list from the consumers grocery store bill and automatically alert the consumer what items are needed to meet a families weekly nutritional requirements.
The DevOps Map: A Poster from the StatisticsMatrix