0

I'm wondering why the max foods is capped out at 10k foods? There are well over 1 million foods in their DB and no matter how I hit that API it maxes out at 10k for for each type (branded, foundation, legacy). Here is my code to prove it:

dataType = 'Branded'
pageNumber = '200'
pageSize = '50'
url = f'https://api.nal.usda.gov/fdc/v1/foods/list?api_key={api_key}&dataType={dataType}&pageNumber={pageNumber}&pageSize={pageSize}'
r = requests.get(url)
print(r.status_code, len(r.json()), r)

dataType = 'Branded'
pageNumber = '201'
pageSize = '50'
url = f'https://api.nal.usda.gov/fdc/v1/foods/list?api_key={api_key}&dataType={dataType}&pageNumber={pageNumber}&pageSize={pageSize}'
r = requests.get(url)
print(r.status_code, len(r.json()), r)

200 50 <Response [200]>

500 5 <Response [500]>

jKraut
  • 2,325
  • 6
  • 35
  • 48
  • 1
    I am not sure why you are getting a 500 response. I checked the documentation and cannot find any issues with your code. I guess in the mean time you can download all 164 millions records (in a json format) by visiting - [https://fdc.nal.usda.gov/download-datasets.html](https://fdc.nal.usda.gov/download-datasets.html) – It_is_Chris Dec 21 '22 at 15:30

0 Answers0