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 Distribution

fooddatacentral-1.0.12.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fooddatacentral-1.0.12-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file fooddatacentral-1.0.12.tar.gz.

File metadata

  • Download URL: fooddatacentral-1.0.12.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for fooddatacentral-1.0.12.tar.gz
Algorithm Hash digest
SHA256 95f2782c11761f47eb3be2fa7ca928b18efd9864717661b5c170179ad2febdeb
MD5 895b6357650cba7f15bc63e046f53f94
BLAKE2b-256 9ed0ca381568799f12ce962b1183b6daebe83ea05076073b524752007e65ee04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fooddatacentral-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 8a749b81283583b8df8c3a19ff7cc0ad4c19dd331dfc299c79c4bef328cffdcc
MD5 feea58439e840d2a4e844662754d8a4e
BLAKE2b-256 8d521aeb01a6f5ffefbec8882e15a23f84abcd303b8d4921b6fe76cbf561a371

See more details on using hashes here.

Supported by

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