pyfdc package¶
Submodules¶
pyfdc.pyfdc module¶
- class pyfdc.pyfdc.FoodDataCentral(api_key=None)[source]¶
Bases:
object
This class provides access to and manipulation of the Food Data Central food search and details end points.
For more details, please see: https://fdc.nal.usda.gov/api-guide.html
This uses version one of the API access point.
- get_food_details(fdc_id=None, target_field=None, result_format='full', nutrients=None)[source]¶
Accesses the FoodDetails EndPoint :param fdc_id: A FoodDataCentral Food ID :param target_field: A string indicating which field to return e.g nutrients If none is provided, a low level result will be returned :return: A DataFrame object with the desired results.
- get_food_info(search_phrase=None, target_fields=None, ingredients=None, brand_owner=None, page_number=1, page_size=50, sort_field=None, sort_direction='asc')[source]¶
- Parameters
search_phrase – A character string to search for.
target_fields – A list of targets eg [‘fdc_id’,’description’]
brand_owner – str Defaults to None
ingredients – str to limit the search to certain ingredients
search_phrase – str A search phrase eg “chicken”
page_number – Page number. Defaults to 1.
page_size – Number of results returned
sort_field – A string specifying which field to use to sort the returned results.
sort_direction – One of “asc” or “desc” to indicate an ascending or descending sort respectively.
- Returns
A pandas DataFrame
- get_food_info_internal(search_phrase=None, ingredients=None, brand_owner=None, target=None, page_number=None, page_size=50, sort_field=None, sort_direction='asc')[source]¶
- Parameters
brand_owner – str Defaults to None
ingredients – str to limit the search to certain ingredients
search_phrase – str A search phrase eg “chicken”
target – A string or list specifying which of the available values should be returned.
page_number – Page number. Defaults to 1.
page_size – Number of results returned
sort_field – A string specifying which field to use to sort the returned results.
sort_direction – One of “asc” or “desc” to indicate an ascending or descending sort respectively.
- Returns
A generator object with the required results.
pyfdc.utils module¶
pyfdc.version module¶
Module contents¶
A python interface to the USDA’s FoodDataCentral API