Skip to main content

Python module to obtain information from the USDA's Food Data Central data project.

Project description

FoodDataCentral

DOI

The USDA maintains a database of nutritional information, where different kinds of food are identified by an FDC number. They do not provide any data on prices.

To look up nutritional information, use api provided by the USDA at https://fdc.nal.usda.gov/. You should sign up for a free api key (see directions on page), then add that key here in place of “DEMOKEY”.

apikey = "DEMO_KEY"  # Replace with a real key!  "DEMO_KEY" will be slow...

Looking up foods

I’ve written a little module fooddatacentral with the methods

  • search
  • nutrients
  • units

FDC Search

Here’s a little code to help look up FDC codes for foods of different descriptions.

import fooddatacentral as fdc

fdc.search(apikey,"crunchy peanut butter")

FDC Nutrients

Once we know the fdc_id of a particular food we can look up a variety of information on it. We start with nutrients

id =     # Put an FDC ID HERE!
fdc.nutrients(apikey,fdc_id=id)

FDC Ingredients

We can also look up the ingredients for many foods (specifically Survey Foods) in the FDC:

fdc.ingredients(apikey,id)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

fooddatacentral-1.0.10-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file fooddatacentral-1.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for fooddatacentral-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1bef6c39bad59a95be193c072b55b1663db7f790540390206b054de1860cce12
MD5 50f74c6df313bae568036be2975c33a8
BLAKE2b-256 36fad2ea5dd742c1d0dbb555b6421ea8fdb379fdf637146a799c3261944611f0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page