Check the setup
- Python 3.10 or newer
- A notebook environment such as Jupyter or Google Colab
- An internet connection
Country food, agriculture, and land-use statistics for building commodity and food-security comparison tools.
From source to product signal
FAOSTAT's JSON API returns one domain, item, and area at a time. Start with wheat production for one country. National questionnaires, modelled estimates, and unit changes all affect comparisons.
Install the packages, then run the notebook cell.
python -m pip install pandas requests
import pandas as pd
import requests
response = requests.get(
"https://fenixservices.fao.org/faostat/api/v1/en/data/QCL",
params={
"area": 231,
"item": 15,
"element": 5510,
"year": "2018,2019,2020,2021,2022",
},
timeout=30,
)
response.raise_for_status()
crops = pd.DataFrame(response.json()["data"])
crops["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
print(crops.head())Test a useful signal
Test whether one FAOSTAT series can power a bounded commodity sketch.
Food and Agriculture Organization of the United Nations is an intergovernmental source. Last verified 2026-08-18. Temporal coverage: item- and country-specific FAOSTAT series.