USDA FDC API & Data Structure - BounSweFerhatSal/NutrAssistant GitHub Wiki

USDA-FDC API

All detailed information can be found at USDA FDC Api Offical Guide , but here is the summary :

We have :

1. Ingredients

2. Nutrition Composition of the Ingredients

To search for an ingredient with the name of it, use below API GET Request :

    https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY&query=ABCDEFGHIJKLMNOP

The response will give a list with data structure :

     -JSON
         -foodSearcCriteria
         -foods
              -food(0....n)
                    -fdcId :       XXXXXX ( Id of the  Ingredient ) 
                    -description : yyyyyy ( Name of the Ingredient ) 

To get the Nutrient composition of an Ingredient, use below API GET Request :

     https://api.nal.usda.gov/fdc/v1/food/######?api_key=DEMO_KEY

The response will give an Object with data structure :

     -JSON
          -fdcId:       XXXXXX ( Id of the  Ingredient ) ( Not important ) 
          -description: yyyyyy ( Name of the Ingredient )( Not Important ) 
          -
          -
          -foodNutrients:
                    -Nutirent(0....n)
                          - type: ( don't care )
                          - id  : ( don't care )
                          - amount : Nutrient Amount in Unit below - - Important !
                          - nutrient : 
                                - id       : Nutrient Id - Important !  
                                - name     : Nutrient Name - Important !  
                                - unitName : Unit  Name - Important !  
                                - id : Nutrient Id - Important !  
                                - id : Nutrient Id - Important !  
                                - id : Nutrient Id - Important !  

Here the "Nutrient Id" is unique and they corresponds to below Nutrients and Parts :

Id Name
Energy 1008
Protein 1003
Carbohydrate 1005
Fat ( Total Lipid) 1004

Others are vitamins , alcohol etc.