Skip to main content

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)

Metadata

Release files for fooddatacentral 1.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fooddatacentral 1.0.12
File Size Uploaded
fooddatacentral-1.0.12.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fooddatacentral 1.0.12
File Interpreter ABI Platform
fooddatacentral-1.0.12-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / fooddatacentral-1.0.12.tar.gz

Download URL fooddatacentral-1.0.12.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
95f2782c11761f47eb3be2fa7ca928b18efd9864717661b5c170179ad2febdeb
BLAKE2b-256 checksum
How to use checksums
9ed0ca381568799f12ce962b1183b6daebe83ea05076073b524752007e65ee04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / fooddatacentral-1.0.12-py3-none-any.whl

Download URL fooddatacentral-1.0.12-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a749b81283583b8df8c3a19ff7cc0ad4c19dd331dfc299c79c4bef328cffdcc
BLAKE2b-256 checksum
How to use checksums
8d521aeb01a6f5ffefbec8882e15a23f84abcd303b8d4921b6fe76cbf561a371
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

1.0.12 This release

2 release files

1.0.11

2 release files

1.0.10

1 release file

1.0.9

2 release files

1.0.8

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page