faostat_get_data
Retrieve rows from one FAOSTAT dataset filtered by area, item, element, year, or other dimension codes; use narrow filters or pagination to handle large result sets.
Instructions
Get one FAOSTAT dataset's rows, filtered by any of its dimensions.
Each row has the dataset's columns. Filter by area, item, element and year, and by any other dimension's id in filters (list_dimensions names them); with no filter it refuses before any request. Without page_size all matching rows come at once: keep filters narrow, or page. Name a country for TM, EA and FT, whose whole years time out (HTTP 504). Codes are FAO's whatever area_cs and item_cs print. A filter of several codes is checked against its list first, an empty answer after: a wrong code, year, dimension or system raises InvalidRequestError naming the closest; else meta.names names each code. meta.vintage is the domain's last update, else None with a note. A call sends at most twelve requests (structure, code lists, data, release date), each tried up to four times, 48 requests at most, a login where the process holds no token, and a login and the request again where FAOSTAT refuses with 401 or 403.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"domain_code": "<domain_code>"
},
"name": "faostat_get_data"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| area | No | One area code or several, FAO's whatever ``area_cs`` says, as ``list_codes(domain_code, "area")`` lists them, e.g. ``"231"`` (United States of America) or ``["231", "79"]``. | |
| item | No | One item code or several, FAO's whatever ``item_cs`` says, as ``list_codes(domain_code, "item")`` lists them, e.g. ``"15"`` (Wheat) or ``["15", "27"]``. | |
| lang | No | Language of the labels and the headers: ``"en"`` (the default), ``"fr"`` or ``"es"``. The rows are read by their columns' descriptions, so a row has the same fields in each. | en |
| year | No | One year or several, each one that ``list_codes(domain_code, "year")`` lists, e.g. ``2020`` or ``[2015, 2016, 2017]``; a year the dataset lacks is refused, and ``get_series`` takes a range instead. FS has no ``year``, which is refused there: its periods are ``year3``, in ``filters`` or through ``get_series``. | |
| area_cs | No | The coding system in which the rows print the area codes, one that the dataset's dimension ``area`` names (``"M49"``, ``"FAO"``, ``"ISO2"`` or ``"ISO3"`` in QCL), or in a dataset without it its countries' dimensions (``reporterarea`` and ``partnerarea`` in TM, ``recipientarea`` in FA and EA, ``"CRS"`` too in EA), checked against its structure before the data; another, or one in a dataset with none of them, is refused. ``None`` prints FAO's codes under ``area_code``; given, the rows print them under a header naming the system, kept in ``columns``, and ``area_code`` is ``None``: ``area="231"`` with ``area_cs="M49"`` prints ``840`` under ``Area Code (M49)``. The filter takes FAO's codes whatever the system, so ``area="840"`` is refused in QCL, whose area list lacks it. | |
| element | No | One element code or several, the filter codes that ``list_codes(domain_code, "element")`` lists, e.g. ``"2510"`` (Production Quantity in QCL), which answers rows whose ``element_code`` is ``"5510"`` (Production); ``5510`` as a filter matches nothing and is refused naming ``2510``. | |
| filters | No | Any other dimension's codes by its id, as ``list_dimensions`` names it, one code or several, as ``list_codes`` lists them, e.g. ``{"month": "7001"}`` (January) for PP, ``{"survey": "024_2024"}`` for MDDW or ``{"reporterarea": "231", "partnerarea": "110"}`` for TM; each sent under its id and checked as the four filters are, an id that the dataset's structure lacks refused. An id that ``get_data`` sends itself (``area``, ``lang``, ``page_size``) is refused before sending. | |
| item_cs | No | The coding system in which the rows print the item codes, one that the dataset's dimension ``item`` names, ``"CPC"`` or ``"FAO"`` in QCL, ``"FBS"`` or ``"FAO"`` in FBS, checked likewise. ``None`` prints FAO's codes under ``item_code``; given, the rows print them under a header naming the system, kept in ``columns``, and ``item_code`` is ``None``: ``item="15"`` with ``item_cs="CPC"`` prints ``0111`` under ``Item Code (CPC)``. | |
| page_size | No | Rows per page, e.g. ``100``; with ``page_number``, one page of the answer. ``None`` returns every row, and ``count_data`` counts them first. One below 1 is refused before sending, since FAOSTAT answers ``0`` with every row. | |
| domain_code | Yes | The domain's code, as ``list_domains`` lists it, e.g. ``"QCL"`` (Crops and livestock products), ``"TCL"`` (trade in crops and livestock products), ``"FBS"`` (Food Balances, 2010-), ``"PP"`` (Producer Prices) or ``"RL"`` (Land Use); one FAOSTAT does not have raises ``NotFoundError``, and an empty text, ``"."`` or ``".."`` is refused before sending. | |
| null_values | No | ``True`` adds the rows of which FAOSTAT holds nothing, without a unit, a value or flags; ``False``, the default, leaves them out. A row whose value is missing comes either way, flagged ``O``, its ``value`` ``None``. | |
| page_number | No | The page to return, from 1, e.g. ``2`` (rows 101 to 200 with ``page_size=100``); without ``page_size`` it is refused before sending, since FAOSTAT answers it alone with every row. |