ParseForge Scrapers

ONS UK Statistics Scraper

parseforge/ons-uk-scraper

BusinessEducationAutomation

Scrapes the ONS Beta API for UK statistics. Returns dataset catalogue, metadata, and observations as flat rows with dimension filters. Export to CSV, JSON, Excel, or XML.

Run this scraper See the API call
Total users
1
Monthly active
0
Total runs
120
Bookmarked
0
Rating
Not rated yet
Last modified
12 days ago

Overview

ParseForge

ONS UK Statistics Scraper

Scrape official UK statistics from the ONS Beta API, from the full dataset catalogue to filtered observations. Every row is a flat record with dataset metadata, edition, version, and dimension values. No API key or registration. Export to CSV, JSON, Excel, or XML.

The ONS publishes the UK's official economic and social statistics, but its Beta API returns nested JSON that is hard to flatten and paginate. This Actor reads the public catalogue, dataset metadata, and observation endpoints directly, applies dimension filters as it goes, and returns each record in one fixed schema. It works for CPI, labour market, wellbeing, and every other dataset in the catalogue.

Who uses it What they scrape ONS UK Statistics for
Market researchers Pull CPI or labour market series for a specific geography and time window.
Data journalists Get the latest wellbeing or crime figures for a story, with full metadata.
Economists Build a clean time series from ONS observations without writing API code.
Open data developers Mirror the ONS catalogue into a local database or data warehouse.

What it does

This Actor collects ONS UK statistics by catalogue, dataset ID, or observation query, and returns each record as a flat row with dataset, edition, version, and dimension values.

  • πŸ“š Catalogue mode: list every dataset in the ONS catalogue, with ID, title, and description.
  • πŸ“„ Dataset mode: fetch metadata, editions, and versions for one dataset or a batch of up to 100 IDs.
  • πŸ“Š Observations mode: pull actual data values from a specific edition and version, with dimension filters.
  • 🧭 Available dimensions mode: list the dimensions and allowed values for a dataset before you query it.

Results export to CSV, JSON, Excel, or XML, or straight from the API.

What you can do with ONS UK Statistics data

πŸ“ˆ Track inflation over time.

An economist runs observations mode on cpih01 with geography and time filters to build a monthly CPI series for a report.

πŸ—ΊοΈ Compare regional labour markets.

A policy analyst pulls the latest employment data for several UK regions and exports it to Excel for a briefing.

πŸ“° Fact-check a news story.

A journalist fetches the latest wellbeing or crime dataset and checks the official figures before publishing.

πŸ—„οΈ Mirror the ONS catalogue.

An open data developer runs catalogue mode weekly and stores the dataset list in a database for a search interface.

Why choose this scraper

What you get
No API key The ONS Beta API is public; this Actor handles the requests and pagination for you.
Flat output Nested JSON is flattened into one row per observation or dataset, ready for CSV or Excel.
Batch lookups Pass up to 100 dataset IDs in one run to fetch metadata for many series at once.
Dimension filtering Filter observations by geography, time, aggregate, and any other dimension with wildcards.

How it compares

No other Store actor targets ONS UK Statistics the same way, so the honest comparison is with the alternatives teams actually weigh.

ONS UK Statistics Scraper Build it in-house By hand
Setup Run it now, zero config Days of engineering None, but hours per pull
When ONS UK Statistics changes Maintained for you You fix it You re-learn the page
Proxies, retries, anti-bot Built in Your problem Browser only
Output Fixed JSON schema, CSV/Excel export Whatever you build Copy-paste
Cost Pay per result Engineering time Analyst hours

Configure the run

Drive the Actor from dataset IDs, edition, version, and dimension filters, and set a maximum number of datasets per run so only the records you need reach your dataset. The Input tab lists every parameter.

A first run with the defaults:

{
  "mode": "catalogue",
  "edition": "time-series",
  "maxItems": 10
}

A larger pull:

{
  "mode": "catalogue",
  "edition": "time-series",
  "maxItems": 200
}

Pricing

Pay-per-result: $0.036 per result collected. You pay only for the results written to your dataset.

Results collected Approximate cost
100 results $3.60
1,000 results $36.00
10,000 results $360.00

New Apify accounts start with $5 in free credit.

Free users

Free-plan runs return up to 10 results as a preview. Upgrade your Apify plan to collect up to 1,000,000 results per run.

Run it

  1. Create a free Apify account with $5 in credit.
  2. Open the ONS UK Statistics Scraper.
  3. Set your inputs and any filters, then click Start.
  4. Export the results as CSV, Excel, JSON, or XML from the Dataset tab.

Run it programmatically through the Apify API (run-sync-get-dataset-items) or the ApifyClient for JavaScript and Python.

Use with AI agents (MCP)

Give an AI agent live access to ONS UK Statistics through the Model Context Protocol. Add the Actor to Claude, Cursor, or any MCP client:

claude mcp add --transport http apify "https://mcp.apify.com?tools=parseforge/ons-uk-scraper"

Then prompt it in plain language to run the scraper and read back the results.

Troubleshooting

Why am I getting no results?

Check that the dataset ID is correct and that the edition and version exist. For observations mode, make sure your dimension filters match allowed values. Run available dimensions mode to see valid options.

Why does the run fail with a 404 error?

The dataset ID, edition, or version may not exist. Verify the ID in catalogue mode and check the dataset's editions and versions in dataset mode.

Why are my dimension filters ignored?

The dimensions input must be a valid JSON object with keys matching the dataset's dimension names. Use available dimensions mode to get the exact names and values.

Why is the run slow?

The ONS API rate limits requests. Reduce maxItems or narrow your dimension filters to fetch fewer records. The Actor respects the API's pagination and retries automatically.

Can I fetch multiple datasets in one run?

Yes, in dataset mode use the datasetIds array to pass up to 100 dataset slugs. For observations, run the Actor once per dataset or use multiple runs.

FAQ

Question Answer
Do I need an API key for the ONS Beta API? No. The ONS Beta API is public and does not require registration or an API key. This Actor makes the requests for you.
How do I find the dataset ID for a statistic? Run the Actor in catalogue mode to list all datasets with their IDs, or use the ONS website to find the slug. Common IDs include cpih01 for CPI and wellbeing-quarterly for wellbeing.
What is the difference between dataset and observations mode? Dataset mode returns metadata about a dataset, including its editions and versions. Observations mode returns the actual data values from a specific edition and version, with optional dimension filters.
Can I filter observations by geography or time? Yes. In observations mode, set the dimensions input to a JSON object like {"geography":"K04000001","time":"*"} to filter by specific values or wildcards.
How many datasets can I fetch in one run? You can set maxItems up to 1,000,000. For dataset mode, you can pass up to 100 dataset IDs in the datasetIds array.
What output formats are supported? The Actor returns data in the Apify dataset, which you can export to CSV, JSON, Excel, or XML from the Apify console or API.
Does this Actor handle pagination? Yes. The Actor automatically follows pagination links from the ONS API until it has collected the requested number of records or reached the end.
Can I get the latest version of a dataset automatically? Yes. Leave the version field empty and the Actor will use the latest version exposed by the dataset.
What is the available dimensions mode for? It lists the dimensions and their allowed values for a dataset, which helps you build the dimensions filter for observations mode.
Is this Actor affiliated with the ONS? No. This is an independent scraper that reads the public ONS Beta API. It is not endorsed by or affiliated with the Office for National Statistics.

Related actors

Browse the full ParseForge collection for more scrapers.

πŸ†˜ Need help? Email parseforge@protonmail.com with your run ID, your input, and what you expected.

⚠️ Disclaimer. This Actor is unofficial and is not affiliated with, endorsed by, or sponsored by Office for National Statistics. It collects only publicly available data. You are responsible for using the collected data in compliance with the source's terms of service and applicable data-protection laws, including GDPR, CCPA, and PIPL. Do not use it to collect personal data unlawfully.

Input

FieldTypeWhat it doesDefault
mode string (4 options) What to scrape from the official ONS UK catalogue: full dataset catalogue, single dataset metadata + editions, or actual observations from a specific version. catalogue
datasetId string ONS dataset slug (e.g. cpih01, wellbeing-quarterly). Required for dataset and observations modes. not set
datasetIds array Array of ONS dataset slugs to fetch in one run (dataset mode). Takes precedence over single datasetId. Max 100 per call. []
edition string Edition slug (default: time-series). Used in observations mode. time-series
version string Version number. Leave empty to use the latest version exposed by the dataset. not set
dimensions object Dimension wildcards used in observations mode, e.g. {"geography":"K04000001","time":"*","aggregate":"cpih1dim1A0"}. Use '*' for any. not set
maxItems integer Maximum number of datasets to collect per run. 10

Pricing

from $27.00 per 1,000 results

Charged forWhat it isPrice each
result Single result in the default dataset. $0.027 to $0.036

Tiered: the lower figure is the price on a higher Apify plan. Billing and the free credit live on Apify.

API

One POST returns the dataset directly. Same shape for every scraper in the library, so swapping the slug is the only change.

POST Β· run and get results
curl -X POST "https://api.apify.com/v2/acts/parseforge~ons-uk-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "helloWorld": 123
  }'

Examples

Input that runs as-is.

input.json
{
  "helloWorld": 123
}

Reviews

No reviews yet. Be the first.

Issues

We build and maintain this scraper, so a problem with it comes to us. Report it on the Apify listing and the thread stays attached to the scraper where the next person can find it: open an issue.

Broken and urgent, or you would rather not post in public? Write to parseforge@protonmail.com and it reaches the people who wrote it.

Related scrapers

Run ONS UK Statistics Scraper on Apify All scrapers