Skip to main content

FoodDataCentral

img

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 "DEMO_KEY".

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
  • ingredients
  • units

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)

Versioning

Releases follow Semantic Versioning. The public API is the functions search, nutrients, ingredients and units: their arguments and the kinds of values they return. Anything else in the package may change without notice.

  • A major release (2.0.0) changes the public API incompatibly.
  • A minor release (1.1.0) adds features, or drops support for a Python version that has reached end of life.
  • A patch release (1.1.1) only fixes bugs.

So a dependency like fooddatacentral>=1.1,<2 will not pick up a release that breaks your code. Releases before 1.1.0 did not follow this scheme.

Metadata

Release files for fooddatacentral 1.1.0

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.1.0
File Size Uploaded Provenance
fooddatacentral-1.1.0.tar.gz 4.4 kB With provenance Details

Built distribution (wheel)

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

Total release size: 9.7 kB

Release files / fooddatacentral-1.1.0.tar.gz

Download URL fooddatacentral-1.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
da44823780a783a0954d303ad92c12fb019604dc279229d67b380de82976683e
BLAKE2b-256 checksum
How to use checksums
b714321e2bcc4db9cbe0a842ad92ab3c821899f239f7774f533f9e7961a90cec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

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

Download URL fooddatacentral-1.1.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07273a13e235a8e6a0162d1cf1332bfff83d59cbf606aa2ed15df4215e97d87b
BLAKE2b-256 checksum
How to use checksums
a2255aac8b1f74da9c9340dd96cac87d43f33b63bc856bc99ff23c492d097d05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for fooddatacentral 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fooddatacentral-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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