faostat_get_codes
Retrieve filter codes for a dimension in a domain, essential before fetching data. Note: element codes differ from display codes—use these for accurate filtering.
Instructions
Get the list of available FILTER codes for a specific dimension in a domain. You MUST call this before faostat_get_data to get the correct codes for filtering.
IMPORTANT: For the 'element' dimension, filter codes differ from the display codes shown in data responses. For example in QCL, faostat_get_codes returns filter code '2510' for Production, but the data response shows '5510' in the Element Code column. Always use the codes from this tool when filtering.
Args: dimension_id: Dimension identifier (e.g. 'area', 'item', 'element', 'year') domain_code: Domain code (e.g. 'QCL', 'TM', 'FS') lang: Language code (default: 'en') limit: Maximum number of codes to return (default: 0 = no limit). Useful for large dimensions like 'item' which can have 1000+ entries.
Examples: faostat_get_codes(dimension_id='element', domain_code='QCL') → Returns element filter codes: 2510=Production, 2312=Area harvested, etc.
faostat_get_codes(dimension_id='area', domain_code='QCL')
→ Returns country/area codes: 2=Afghanistan, 3=Albania, etc.TIP: To find a code by name (e.g. 'production', 'wheat', 'Nigeria'), use faostat_search_codes instead — it returns filtered results and signals whether the match is unambiguous before you proceed to faostat_get_data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dimension_id | Yes | ||
| domain_code | Yes | ||
| lang | No | en | |
| limit | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |