FoodDataCentral
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
searchnutrientsunits
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)
| File | Size | Uploaded | |
|---|---|---|---|
| fooddatacentral-1.0.12.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|