Explore topics and datasets
Navigate the ONS topic hierarchy to discover dataset IDs, inspect dimension structure, and find the right version to query — without knowing anything upfront.
If you know you need "population statistics by region" or "labour market data broken down by age" but don't know the dataset ID, start here. This guide walks through the ONS topic tree from top-level navigation down to dataset dimensions and available option values.
The discovery hierarchy
ONS organises its content in two parallel structures you can navigate:
Topic tree — a hierarchical taxonomy (Economy → Prices → Consumer price inflation). Use getNavigation, getTopics, getTopic, and getTopicSubtopics to walk it, then getTopicContent to list datasets and timeseries within a leaf topic.
Dataset catalogue — a flat list of all published datasets with pagination. Use getDatasets when you want to browse everything, or getDataset when you already have an ID.
Once you have a dataset ID, navigate its edition → version → dimensions hierarchy to understand its structure before querying data.
Step 1: Get the top-level navigation
getNavigation returns the root topic tree — the same structure that powers the ONS website's main navigation. Each item has a slug and optional subtopics.
Step 2: Drill into topics
getTopics returns the full list of top-level topics. Each Topic has an id you can use with getTopic and getTopicSubtopics.
Navigate to subtopics using getTopicSubtopics:
Step 3: List content within a topic
getTopicContent returns the datasets and timeseries published under a topic. Each item includes a type field ('dataset' or 'timeseries') and a links object pointing to the resource.
Step 4: Browse datasets directly
When you want to explore all available datasets rather than navigating by topic, use getDatasets. It supports pagination via limit and offset.
Inspect a single dataset by ID:
Step 5: Navigate editions and versions
Datasets are versioned. You must select an edition and version to query data. Most datasets have a single edition (typically named 'time-series'), and the latest version is what you want for current data.
Always retrieve the version list rather than hardcoding a version number. Versions increment with each release and the current version number will change as ONS publishes updates.
Step 6: Inspect dimensions
getDatasetDimensions returns the full list of dimensions for a specific dataset version. Each dimension has a name, label, and description.
Step 7: List available dimension options
Before querying observations or creating a filter, you need to know what values are valid for each dimension. getDatasetDimensionOptions returns all available option codes and labels.
Complete walkthrough: CPIH dataset discovery
Starting from navigation, arriving at geography dimension options.
Working with code lists
Some datasets reference ONS code lists — classification reference data that maps option codes to labels and hierarchies. The getCodeLists, getCodeList, and related methods let you inspect these:
Code list data is useful when you need human-readable labels for dimension option codes, or when building UI components that let users select dimension values.