USDA / USDA-APIs

Do you have feedback, ideas, or questions for USDA APIs? Use this repository's Issue Tracker to join the discussion.
www.usda.gov/developer
107 stars 16 forks source link

Reg: Group Id's #90

Open manijcgvak opened 4 years ago

manijcgvak commented 4 years ago

Hello, For our application, with old API we use the below URL to get the groups and used it for one of our scenario.

Example:

http://api.nal.usda.gov/ndb/list?lt=g

Result:

{ "list": { "lt": "g", "start": 0, "end": 26, "total": 26, "sr": "1", "sort": "n", "item": [ { "offset": 0, "id": "3500", "name": "American Indian/Alaska Native Foods" }, { "offset": 1, "id": "0300", "name": "Baby Foods" }, { "offset": 2, "id": "1800", "name": "Baked Products" }, { "offset": 3, "id": "1300", "name": "Beef Products" }, { "offset": 4, "id": "1400", "name": "Beverages" }, { "offset": 5, "id": "0800", "name": "Breakfast Cereals" }, { "offset": 6, "id": "2000", "name": "Cereal Grains and Pasta" }, { "offset": 7, "id": "0100", "name": "Dairy and Egg Products" }, { "offset": 8, "id": "2100", "name": "Fast Foods" }, { "offset": 9, "id": "0400", "name": "Fats and Oils" }, { "offset": 10, "id": "1500", "name": "Finfish and Shellfish Products" }, { "offset": 11, "id": "0900", "name": "Fruits and Fruit Juices" }, { "offset": 12, "id": "1700", "name": "Lamb, Veal, and Game Products" }, { "offset": 13, "id": "1600", "name": "Legumes and Legume Products" }, { "offset": 14, "id": "2200", "name": "Meals, Entrees, and Side Dishes" }, { "offset": 15, "id": "1200", "name": "Nut and Seed Products" }, { "offset": 16, "id": "1000", "name": "Pork Products" }, { "offset": 17, "id": "0500", "name": "Poultry Products" }, { "offset": 18, "id": "3600", "name": "Restaurant Foods" }, { "offset": 19, "id": "0700", "name": "Sausages and Luncheon Meats" }, { "offset": 20, "id": "2500", "name": "Snacks" }, { "offset": 21, "id": "0600", "name": "Soups, Sauces, and Gravies" }, { "offset": 22, "id": "0200", "name": "Spices and Herbs" }, { "offset": 23, "id": "1900", "name": "Sweets" }, { "offset": 24, "id": "1100", "name": "Vegetables and Vegetable Products" } ] } }

Now, In new API how can we get this group json result?

littlebunch commented 4 years ago

@manijcgvak Groups/categories are not included in the latest spec for the list endpoint. A complicating factor is that there is no common set of terms used across all data types. The old API used the categories for Standard Legacy, FNDDS has it's own categories, Branded has several, etc. Groups/categories for the various data types. are available in the csv files available for downloading.

s-h-a-d-o-w commented 4 years ago

I don't understand why it has to be an "all or nothing" approach. Why not let people query e.g. "all foods that belong to category ABC of data source XYZ"?

Are there really so few apps that use the USDA API that breaking changes like this are no big deal? When I read that there would be a new API, I considered it a given that my app (fructosedb) would keep on working, I might just have to change my queries. But at this rate, I guess I'll just have to scrape the current data and consider it "still better than the short list of foods doctors give you".