fetch_data
Fetch observations from a NOMIS dataset using dimension filters; returns matching rows with total count and truncation flag to prevent interpreting incomplete results.
Instructions
Fetch observations from a dataset. Codes must come from search_codes.
Returns rows plus 'total', the number of records matching the query, and 'truncated'. Read them. NOMIS answers an oversized query with HTTP 200 and a body cut short with no error, so a result can look complete while holding a small fraction of the data. Never total, average or rank a truncated result; narrow the filters, or use fetch_data_to_file.
A worked example, claimant count for Bristol in the latest month:
fetch_data('NM_1_1', {'geography': '1778384919', 'sex': '7',
'item': '1', 'measures': '20100',
'time': 'latest'})Requesting a whole geography type (e.g. 'TYPE151' for 2021 LSOAs) across several dimensions produces millions of records. Use fetch_data_to_file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| select | No | Columns to return. Defaults to date, geography name and code, and value. Fewer columns means a smaller result. | |
| filters | Yes | Dimension filters, keyed by the concept names from get_dataset_dimensions, with values from search_codes. Comma-separate multiple codes. Examples: {'geography': '1778384919', 'sex': '7', 'item': '1', 'measures': '20100', 'time': 'latest'}. geography also accepts a range '1774190614...1774190617', a whole type 'TYPE424', 'POSTCODE|bs1 5tr;424', 'LATLONG|51.45;-2.58;424', or 'MAKE|my area|2013265921;2013265922'. time accepts 'latest', 'latestMINUS12', 'previous', 'prevyear', 'first', or a date '2026-07'. | |
| dataset_id | Yes | Dataset id, e.g. NM_1_1 | |
| record_limit | No | Maximum rows to return | |
| record_offset | No | Rows to skip |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||