What’s covered
Every price is grouped the way USDA Market News groups it: acategory, then a commodity inside it. Pass either one, or both, to List Commodities. ?category=grains&commodity=corn lists every corn price series.
A few groupings follow USDA rather than the grocery aisle: eggs are under
poultry, and soybeans, oilseeds and dry beans are under grains, because USDA reports them in its grain bids. Where USDA splits one crop into types, such as bell and jalapeño peppers or grape and plum tomatoes, the crop is the commodity and the type is one of its attributes. Sweet corn is sweet_corn under vegetables; corn under grains is field corn.
Fruit and vegetables include every product the USDA has priced within two years of its newest report, each with its full history.
Find a series in four layers
Each price series answers four questions, and List Commodities can narrow on each one:
Each result is one series: its
id and metric_name, the product it prices (its category, commodity and attributes), then one field for each market and series layer, named exactly like the parameter that filters it. You never have to take a metric_name apart, because every part of it is also its own field.
List commodities
GET /v1/commodities lists price series, narrowed by any of the four layers, one page at a time. It is free.
first_observed_on and last_observed_on to see how far back a series goes and how fresh it is before you ask for its values. When next_cursor is null, you have reached the last page. The --globoff flag stops curl from reading the square brackets in attributes[...] as a pattern.
Get commodity metric values
GET /v1/commodities/metric-values returns dated values for one or more series. It costs $0.01 per call, however many series you ask for.
When you leave out the dates
If you leave outstart_date, each series returns a recent stretch. How long depends on how often the series is published:
The stretch is counted back from
end_date if you pass it. If you don’t, it is counted back from the series’ own newest value, not from today, so a series that stopped updating still returns its last stretch. Each series is counted on its own, so two series in one call can start on different dates.
Pass start_date to get an exact range, or an early date such as start_date=1990-01-01 to get a series’ full history.
Understanding the response
datahas one entry per series you asked for, in the order you asked.- Each entry describes the series with the same fields as List Commodities, then adds
start_date,end_dateandvalues. start_dateandend_dateare the first and last dates used for that series. They arenullonly when you passed no dates and the series has no values at all.unittells you how to readvalue. For example,usd_per_lbis dollars per pound.valuesis in date order, with onevalueper date. Days with no value, such as weekends for a daily series, are left out.valueis the number the USDA published, in the series’ unit. A price the USDA publishes in cents is given in dollars.- A date range with no values returns the series with an empty
valuesarray, not an error.
400, and the message names the ones it doesn’t know. So a typo never silently drops a series.
400 Unknown metric
Series fields
Returned by both endpoints, insidedata[].
Get Commodity Metric Values adds:
Validation rules
Summary
What to do next
- Try it live: List Commodities and Get Commodity Metric Values.
- Copy a working feature: see the Food Commodity Prices cookbook examples.
- Handle errors: see Errors.
- Let your AI assistant do it: see Use With Claude.