Check the setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- A free NASS API key saved in the NASS_API_KEY environment variable
Official U.S. agricultural survey and census estimates for building commodity and county production monitors.
From source to product signal
Quick Stats exposes published NASS survey and census estimates. Start with one commodity, one state, one statistic, and one year so the request stays under the 50,000-row cap. Display the required NASS disclaimer, and do not treat a single-year extract as a complete national inventory.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import os
import pandas as pd
import requests
params = {
"key": os.environ["NASS_API_KEY"],
"commodity_desc": "CORN",
"statisticcat_desc": "YIELD",
"agg_level_desc": "STATE",
"state_alpha": "IA",
"year": 2024,
"format": "JSON",
}
response = requests.get(
"https://quickstats.nass.usda.gov/api/api_GET/",
params=params,
timeout=30,
)
response.raise_for_status()
estimates = pd.DataFrame(response.json()["data"])
estimates["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
print(estimates[["short_desc", "state_alpha", "year", "Value", "unit_desc"]].head(20))Test a useful signal
Retrieve published Iowa corn-yield estimates for one year and record their units.
USDA National Agricultural Statistics Service is a government source. Last verified 2026-08-14. Temporal coverage: Census of Agriculture years plus ongoing surveys.