Models API
The models module provides data models for the USDA Food Data Central API responses.
Food
- class usda_fdc.models.Food(fdc_id, description, data_type, publication_date=None, food_class=None, food_category=None, scientific_name=None, brand_owner=None, brand_name=None, ingredients=None, serving_size=None, serving_size_unit=None, household_serving_fulltext=None, nutrients=<factory>, food_portions=<factory>)[source]
Bases:
objectRepresents a food item from the FDC database.
- Parameters:
fdc_id (int) –
description (str) –
data_type (str) –
publication_date (str | None) –
food_class (str | None) –
food_category (str | None) –
scientific_name (str | None) –
brand_owner (str | None) –
brand_name (str | None) –
ingredients (str | None) –
serving_size (float | None) –
serving_size_unit (str | None) –
household_serving_fulltext (str | None) –
food_portions (List[FoodPortion]) –
- food_portions: List[FoodPortion]
- __init__(fdc_id, description, data_type, publication_date=None, food_class=None, food_category=None, scientific_name=None, brand_owner=None, brand_name=None, ingredients=None, serving_size=None, serving_size_unit=None, household_serving_fulltext=None, nutrients=<factory>, food_portions=<factory>)
- Parameters:
fdc_id (int) –
description (str) –
data_type (str) –
publication_date (str | None) –
food_class (str | None) –
food_category (str | None) –
scientific_name (str | None) –
brand_owner (str | None) –
brand_name (str | None) –
ingredients (str | None) –
serving_size (float | None) –
serving_size_unit (str | None) –
household_serving_fulltext (str | None) –
food_portions (List[FoodPortion]) –
- Return type:
None
Nutrient
FoodPortion
- class usda_fdc.models.FoodPortion(id, amount, gram_weight, portion_description=None, modifier=None, measure_unit=None)[source]
Bases:
objectRepresents a food portion.
- Parameters:
SearchResult
- class usda_fdc.models.SearchResult(foods, total_hits, current_page, total_pages)[source]
Bases:
objectRepresents search results from the FDC API.
- Parameters:
foods (List[SearchResultFood]) –
total_hits (int) –
current_page (int) –
total_pages (int) –
- foods: List[SearchResultFood]
SearchResultFood
- class usda_fdc.models.SearchResultFood(fdc_id, description, data_type, publication_date=None, food_category=None, brand_owner=None, brand_name=None)[source]
Bases:
objectRepresents a food item in search results.
- Parameters:
- classmethod from_api_data(data)[source]
Create a SearchResultFood instance from API data.
- __init__(fdc_id, description, data_type, publication_date=None, food_category=None, brand_owner=None, brand_name=None)