# ONS UK Statistics Beta API Scraper (`parseforge/ons-uk-scraper`) Actor

Scrape the UK Office for National Statistics (ONS) Beta API. Pull the dataset catalogue, dataset-level metadata, editions, versions and CSV-style observations across themes including economy, population, labour market and inflation.

- **URL**: https://apify.com/parseforge/ons-uk-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** Business, Education, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $27.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

![ParseForge Banner](https://github.com/ParseForge/apify-assets/blob/main/banners/banner-default.jpg?raw=true)

## 📊 ONS UK Statistics Scraper

> 🚀 **Export the official UK statistical catalogue in seconds.** Pull the **full ONS dataset catalogue**, dataset metadata, editions, versions, available dimensions, and CSV-style observation values across inflation, the labour market, population, GDP, wellbeing, and more. No sign-up needed.

> 🕒 **Last updated:** 2026-05-15 · **📊 22 fields** per record · **📦 300+ datasets** · **🇬🇧 National + regional + local-authority coverage**

The **ONS UK Statistics Scraper** taps the official UK Office for National Statistics catalogue and returns clean, structured records covering every published dataset. Pull dataset titles, descriptions, release frequencies, next-release dates, methodologies, related publications, dimension lists, and observation values keyed by geography, time, and analytic dimensions.

The catalogue spans **300+ active datasets**, including CPIH inflation, labour-force survey, GDP estimates, population projections, regional wellbeing, and dozens of bespoke survey publications. Coverage runs from the UK level down to local-authority districts. This Actor turns the entire catalogue, single-dataset metadata, dimension-options helper, and version-level observations into downloadable CSV, Excel, JSON, or XML in minutes.

| 🎯 Target Audience | 💡 Primary Use Cases |
|---|---|
| Economists, journalists, fintech & PropTech teams, policy analysts, researchers, BI engineers, civic-tech developers | Inflation tracking, GDP nowcasting, labour-market dashboards, regional analytics, BBC-style newsroom charts, ML feature engineering, Power BI / Tableau feeds |

---

### 📋 What the ONS UK Scraper does

Four workflows in a single Actor:

- 📚 **Catalogue mode.** List every published ONS dataset with title, description, release frequency, next-release date, keywords, contacts, methodologies, related publications, and the latest version pointer.
- 🧾 **Dataset mode.** Pull the full metadata for one dataset or batch up to 100 dataset slugs in a single run. Includes editions, versions, taxonomy, and quality-management information.
- 🗂️ **Available dimensions mode.** Helper that lists every dimension and its full set of options for a dataset version — so you know which filter codes to plug into observations mode.
- 📈 **Observations mode.** Download observation values for any dataset version with optional dimension filters (geography codes, time, analytic axes).

Every record carries the official ONS deep link, so you can verify any number against the source page in one click.

> 💡 **Why it matters:** UK official statistics underpin lending decisions, public-policy research, regional economic strategy, journalism, and academic work. Building your own pipeline against the official catalogue means handling pagination, edition resolution, dimension decoding, and CSV parsing by hand. This Actor skips all of that and keeps your dataset fresh on every run.

---

### 🎬 Full Demo

_🚧 Coming soon: a 3-minute walkthrough showing how to go from sign-up to a downloaded dataset._

---

### ⚙️ Input

<table>
<thead>
<tr><th>Input</th><th>Type</th><th>Default</th><th>Behavior</th></tr>
</thead>
<tbody>
<tr><td><code>mode</code></td><td>enum</td><td><code>"catalogue"</code></td><td>One of <code>catalogue</code>, <code>dataset</code>, <code>observations</code>, <code>availableDimensions</code>.</td></tr>
<tr><td><code>datasetId</code></td><td>string</td><td><code>""</code></td><td>ONS dataset slug (e.g. <code>cpih01</code>, <code>wellbeing-quarterly</code>). Required for dataset, observations, and availableDimensions modes.</td></tr>
<tr><td><code>datasetIds</code></td><td>array</td><td><code>[]</code></td><td>Batch lookup for dataset mode. Up to 100 slugs per run. Takes precedence over <code>datasetId</code>.</td></tr>
<tr><td><code>edition</code></td><td>string</td><td><code>"time-series"</code></td><td>Edition slug used in observations and availableDimensions modes.</td></tr>
<tr><td><code>version</code></td><td>string</td><td><code>""</code></td><td>Version number. Leave empty to use the latest version.</td></tr>
<tr><td><code>dimensions</code></td><td>object</td><td><code>{}</code></td><td>Dimension wildcards for observations mode, e.g. <code>{"geography":"K04000001","time":"*","aggregate":"cpih1dim1A0"}</code>. Use <code>"*"</code> for any.</td></tr>
<tr><td><code>maxItems</code></td><td>integer</td><td><code>10</code></td><td>Records to return. Free plan caps at 10, paid plan at 1,000,000.</td></tr>
</tbody>
</table>

**Example: full ONS catalogue (first 50 datasets).**

```json
{
    "mode": "catalogue",
    "maxItems": 50
}
````

**Example: latest CPIH inflation observations for England and Wales.**

```json
{
    "mode": "observations",
    "datasetId": "cpih01",
    "edition": "time-series",
    "dimensions": {
        "geography": "K04000001",
        "time": "*",
        "aggregate": "cpih1dim1A0"
    },
    "maxItems": 100
}
```

> ⚠️ **Good to Know:** ONS dataset slugs are short (e.g. `cpih01`, `weekly-deaths-region`). Use `catalogue` mode first to discover slugs, then switch to `availableDimensions` to learn the valid filter codes for the dataset, then to `observations` to pull values. Geography codes follow the ONS Standard Geography Code (e.g. `K04000001` = England and Wales, `E92000001` = England).

***

### 📊 Output

Each record contains up to **22 fields** depending on mode. Download the dataset as CSV, Excel, JSON, or XML.

#### 🧾 Schema

| Field | Type | Example |
|---|---|---|
| 🆔 `id` | string | `"cpih01"` |
| 🔗 `url` | string | `"https://www.ons.gov.uk/datasets/cpih01"` |
| 🏷️ `title` | string | `"Consumer Prices Index including owner occupiers' housing costs (CPIH)"` |
| 📝 `description` | string | `"A comprehensive measure of inflation that includes owner occupiers' housing costs..."` |
| 🚦 `state` | string | `"published"` |
| 🏛️ `national_statistic` | boolean | `true` |
| 🔁 `release_frequency` | string | `"Monthly"` |
| 📅 `next_release` | string | `"22 May 2026"` |
| 📅 `nextReleaseDate` | ISO 8601 | `"2026-05-22T00:00:00.000Z"` |
| 📐 `unit_of_measure` | string | `"Index"` |
| 🪪 `license` | string | `"Open Government Licence v3.0"` |
| 🕒 `last_updated` | string | `"2026-04-17T07:00:00.000Z"` |
| 🏷️ `keywords` | array | `["inflation","cpi","cpih","prices"]` |
| 📞 `contacts` | array | `[{ "name": "Consumer Prices Team", "email": "..." }]` |
| 📄 `qmi` | string | `"https://www.ons.gov.uk/economy/inflationandpriceindices/qmis/..."` |
| 📚 `methodologies` | array | `[{ "title": "CPIH methodology", "href": "..." }]` |
| 🔗 `publications` | array | `[{ "title": "Consumer price inflation, UK: April 2026", "href": "..." }]` |
| 🔗 `related_datasets` | array | `[{ "title": "Producer price inflation", "href": "..." }]` |
| 🔢 `latest_version` | string | `"148"` |
| 🗂️ `editions` | array | `[{ "edition": "time-series", "state": "published", "latest_version": "148" }]` |
| 💰 `value` | number | `132.4` |
| 📐 `dimensions` | object | `{ "geography": "K04000001", "time": "Apr-26", "aggregate": "cpih1dim1A0" }` |
| 🕒 `scrapedAt` | ISO 8601 | `"2026-05-15T10:00:00.000Z"` |

#### 📦 Sample record (catalogue mode)

<details>
<summary><strong>📊 CPIH inflation dataset (cpih01)</strong></summary>

```json
{
    "id": "cpih01",
    "url": "https://www.ons.gov.uk/datasets/cpih01",
    "title": "Consumer Prices Index including owner occupiers' housing costs (CPIH)",
    "description": "A comprehensive measure of inflation that includes owner occupiers' housing costs and Council Tax.",
    "state": "published",
    "national_statistic": true,
    "release_frequency": "Monthly",
    "next_release": "22 May 2026",
    "nextReleaseDate": "2026-05-22T00:00:00.000Z",
    "unit_of_measure": "Index",
    "last_updated": "2026-04-17T07:00:00.000Z",
    "keywords": ["inflation", "cpi", "cpih", "prices"],
    "latest_version": "148",
    "scrapedAt": "2026-05-15T10:00:00.000Z"
}
```

</details>

<details>
<summary><strong>📈 Observations mode: monthly CPIH value</strong></summary>

```json
{
    "datasetId": "cpih01",
    "edition": "time-series",
    "version": "148",
    "url": "https://www.ons.gov.uk/datasets/cpih01/editions/time-series/versions/148",
    "value": 132.4,
    "dimensions": {
        "geography": "K04000001",
        "time": "Apr-26",
        "aggregate": "cpih1dim1A0"
    },
    "unit_of_measure": "Index",
    "scrapedAt": "2026-05-15T10:00:00.000Z"
}
```

</details>

***

### ✨ Why choose this Actor

| | Capability |
|---|---|
| 🇬🇧 | **Full ONS catalogue.** 300+ datasets across inflation, labour, GDP, population, wellbeing, and more. |
| 🗂️ | **Edition + version aware.** Pull the latest version automatically or pin to a historical edition. |
| 🧾 | **Batch metadata.** Up to 100 dataset slugs in one run with editions and versions resolved. |
| 🗺️ | **Dimension helper.** Discover the valid filter codes for any dataset version before pulling observations. |
| 🔁 | **Always fresh.** Every run reflects the current state of the official catalogue. |
| 🧰 | **No setup.** No sign-up, no key, no scraping CSS selectors. |
| 🔗 | **Source-anchored.** Every record carries the official ONS deep link. |

> 📊 The ONS is the most-cited reference for UK inflation, employment, GDP, and population data. This Actor makes it queryable in seconds.

***

### 📈 How it compares to alternatives

| Approach | Cost | Coverage | Refresh | Filters | Setup |
|---|---|---|---|---|---|
| **⭐ ONS UK Scraper** *(this Actor)* | $5 free credit, then pay-per-use | **300+ datasets, regional + LA detail** | **Live per run** | catalogue, dataset, observations, dimensions | ⚡ 2 min |
| Manual CSV downloads | Free | Per-dataset only | Manual | None | 🐢 Hours per dataset |
| Macro-data terminals | $24,000+/year | Curated subset | Live | Many | ⏳ Days |
| Build your own pipeline | Engineering hours | What you build | What you build | What you build | 🕒 Weeks |

Pick this Actor when you want broad UK coverage, server-side filtering, and no parser maintenance.

***

### 🚀 How to use

1. 📝 **Sign up.** [Create a free account with $5 credit](https://console.apify.com/sign-up?fpr=vmoqkp) (takes 2 minutes).
2. 🌐 **Open the Actor.** Go to the ONS UK Statistics Scraper page on the Apify Store.
3. 🎯 **Set input.** Pick a mode (start with `catalogue` to browse), set `maxItems`, and click Start.
4. 🚀 **Run it.** Click **Start** and let the Actor collect your data.
5. 📥 **Download.** Grab your results in the **Dataset** tab as CSV, Excel, JSON, or XML.

> ⏱️ Total time from signup to downloaded dataset: **3-5 minutes.** No coding required.

***

### 💼 Business use cases

<table>
<tr>
<td width="50%" valign="top">

#### 🏦 Banking, fintech, and insurance

- Live CPIH inflation feeds for retail-rate dashboards
- Mortgage and insurance underwriting fed by labour-market and earnings data
- Macro-forecasting models with quarterly GDP estimates
- Risk dashboards aligned with ONS official statistics

</td>
<td width="50%" valign="top">

#### 🏘️ PropTech and real estate

- Local-authority population and household projections for site selection
- Regional wage and employment data for valuation models
- Construction output and house-price indices
- Demographic shifts feeding tenant-targeting

</td>
</tr>
<tr>
<td width="50%" valign="top">

#### 📊 Market research and consulting

- Industry GDP, productivity, and earnings benchmarks
- Retail sales, services turnover, and producer prices
- Consumer trends from the household-spending survey
- Sector deliverables backed by official UK numbers

</td>
<td width="50%" valign="top">

#### 📰 Journalism and policy

- Live charts of inflation, jobs, and GDP for newsrooms
- Regional explainers backed by local-authority data
- Public-policy briefs with cited, versioned numbers
- Investigative reporting on housing, health, and wellbeing

</td>
</tr>
</table>

***

### 🔌 Automating ONS UK Scraper

Control the scraper programmatically for scheduled runs and pipeline integrations:

- 🟢 **Node.js.** Install the `apify-client` NPM package.
- 🐍 **Python.** Use the `apify-client` PyPI package.
- 📚 See the [Apify API documentation](https://docs.apify.com/api/v2) for full details.

The [Apify Schedules feature](https://docs.apify.com/platform/schedules) lets you trigger this Actor on any cron interval. Daily refreshes for high-frequency datasets (CPIH, labour market, GDP estimates) keep dashboards current with no engineering effort.

***

### 🌟 Beyond business use cases

Data like this powers more than commercial workflows. The same structured records support research, education, civic projects, and personal initiatives.

<table>
<tr>
<td width="50%">

#### 🎓 Research and academia

- Macroeconomic theses with cited, versioned dataset pulls
- Public-health and demographic research at the regional level
- Reproducible studies with stable dataset slugs and versions
- Open-data exercises in econometrics and stats courses

</td>
<td width="50%">

#### 🎨 Personal and creative

- Side projects, indie data dashboards, and portfolio demos
- Interactive UK maps, inflation trackers, and visualizations
- Content research for data journalists and creators
- Hobbyist time-series for forecasters and analysts

</td>
</tr>
<tr>
<td width="50%">

#### 🤝 Non-profit and civic

- Equity research on regional income, housing, and labour outcomes
- Civic transparency on public spending and services
- Investigative journalism backed by ONS official numbers
- Open data community contributions and visualizations

</td>
<td width="50%">

#### 🧪 Experimentation

- Train forecasting and anomaly-detection ML models
- Validate macro hypotheses with real time-series
- Prototype agent pipelines that resolve dataset slugs
- Test BI dashboard concepts with live UK data

</td>
</tr>
</table>

***

### 🤖 Ask an AI assistant about this scraper

Open a ready-to-send prompt about this ParseForge actor in the AI of your choice:

- 💬 [**ChatGPT**](https://chat.openai.com/?q=How%20do%20I%20use%20the%20ONS%20UK%20Statistics%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🧠 [**Claude**](https://claude.ai/new?q=How%20do%20I%20use%20the%20ONS%20UK%20Statistics%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🔍 [**Perplexity**](https://perplexity.ai/search?q=How%20do%20I%20use%20the%20ONS%20UK%20Statistics%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🅒 [**Copilot**](https://copilot.microsoft.com/?q=How%20do%20I%20use%20the%20ONS%20UK%20Statistics%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)

***

### ❓ Frequently Asked Questions

#### 🧩 How does it work?

Pick a mode (catalogue, dataset, observations, available dimensions), set the dataset slug or filters, and click Start. The Actor pulls clean structured records straight from the official ONS catalogue. No browser automation, no captchas, no setup.

#### 📏 How accurate is the data?

Every value comes directly from the official ONS catalogue, the canonical source for UK official statistics. No transformation is applied beyond field-name normalization and ISO timestamp stamping.

#### 🔁 How often is the catalogue refreshed?

The catalogue is updated continuously as ONS releases new datasets and revises existing versions. Every run of this Actor returns the live state of the catalogue.

#### 🗺️ How do I pull regional or local-authority data?

Use `availableDimensions` mode to discover the geography codes a dataset supports, then pass the code in the `dimensions.geography` filter when running `observations` mode. ONS Standard Geography codes look like `K04000001` (England and Wales) or `E08000003` (Manchester).

#### ⏰ Can I schedule regular runs?

Yes. Use Apify Schedules to run this Actor on any cron interval (hourly, daily, weekly) and keep your downstream database in sync with new ONS releases.

#### ⚖️ Is this data legal to use?

ONS publishes under the Open Government Licence v3.0, which permits commercial and non-commercial use with attribution. Review the licence terms for your specific use case.

#### 💼 Can I use this data commercially?

Yes. The underlying ONS data is open and permits commercial use with attribution. You are responsible for complying with the licence and with any downstream regulatory requirements.

#### 💳 Do I need a paid Apify plan to use this Actor?

No. The free Apify plan is enough for testing and small runs (10 records per run). A paid plan lifts the limit and gives you access to scheduling, higher concurrency, and larger datasets.

#### 🔁 What happens if a run fails or gets interrupted?

Apify automatically retries transient errors. If a run still fails, you can inspect the log in the Runs tab, fix the input, and re-run. Partial datasets from failed runs are preserved so you never lose progress.

#### 📝 Why are some datasets missing fields?

Not every ONS dataset publishes the same metadata blocks (methodologies, publications, related datasets). When a block is empty in the source, the corresponding field is returned as `null` or an empty array.

#### 🆘 What if I need help?

Our support team is here to help. Contact us through the Apify platform or use the Tally form linked below.

***

### 🔌 Integrate with any app

ONS UK Scraper connects to any cloud service via [Apify integrations](https://apify.com/integrations):

- [**Make**](https://docs.apify.com/platform/integrations/make) - Automate multi-step workflows
- [**Zapier**](https://docs.apify.com/platform/integrations/zapier) - Connect with 5,000+ apps
- [**Slack**](https://docs.apify.com/platform/integrations/slack) - Get run notifications in your channels
- [**Airbyte**](https://docs.apify.com/platform/integrations/airbyte) - Pipe ONS records into your warehouse
- [**n8n**](https://n8n.io) - Self-hosted workflow automation
- [**Pipedream**](https://pipedream.com) - Event-driven serverless workflows
- [**GitHub**](https://docs.apify.com/platform/integrations/github) - Trigger runs from commits and releases
- [**Google Drive**](https://docs.apify.com/platform/integrations/drive) - Export datasets straight to Sheets

You can also use webhooks to trigger downstream actions when a run finishes. Push fresh CPIH or labour-market numbers into your product backend, or alert your team in Slack the minute a new release lands.

***

### 🔗 Recommended Actors

- [**📊 Statistics Canada Scraper**](https://apify.com/parseforge/statistics-canada-scraper) - Canadian official statistics catalogue
- [**📊 INE Spain Scraper**](https://apify.com/parseforge/ine-spain-scraper) - Spanish National Statistics Institute
- [**📊 INE Portugal Scraper**](https://apify.com/parseforge/ine-portugal-scraper) - Statistics Portugal indicators
- [**📊 IBGE Brazil Scraper**](https://apify.com/parseforge/ibge-brazil-scraper) - Brazilian Institute of Geography and Statistics
- [**📈 Indexmundi Scraper**](https://apify.com/parseforge/indexmundi-scraper) - Global demographic and economic indicators

> 💡 **Pro Tip:** browse the complete [ParseForge collection](https://apify.com/parseforge) for more reference-data scrapers.

***

**🆘 Need Help?** [**Open our contact form**](https://tally.so/r/BzdKgA) to request a new scraper, propose a custom data project, or report an issue.

***

> **⚠️ Disclaimer:** this Actor is an independent tool and is not affiliated with, endorsed by, or sponsored by the Office for National Statistics or the UK Government. All trademarks mentioned are the property of their respective owners. Only publicly available open data is collected.

# Actor input Schema

## `mode` (type: `string`):

What to scrape from the official ONS UK catalogue: full dataset catalogue, single dataset metadata + editions, or actual observations from a specific version.

## `datasetId` (type: `string`):

ONS dataset slug (e.g. cpih01, wellbeing-quarterly). Required for dataset and observations modes.

## `datasetIds` (type: `array`):

Array of ONS dataset slugs to fetch in one run (dataset mode). Takes precedence over single datasetId. Max 100 per call.

## `edition` (type: `string`):

Edition slug (default: time-series). Used in observations mode.

## `version` (type: `string`):

Version number. Leave empty to use the latest version exposed by the dataset.

## `dimensions` (type: `object`):

Dimension wildcards used in observations mode, e.g. {"geography":"K04000001","time":"*","aggregate":"cpih1dim1A0"}. Use '*' for any.

## `maxItems` (type: `integer`):

Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000

## Actor input object example

```json
{
  "mode": "catalogue",
  "datasetIds": [],
  "edition": "time-series",
  "maxItems": 10
}
```

# Actor output Schema

## `overview` (type: `string`):

Overview of scraped data

## `fullData` (type: `string`):

Complete dataset

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "catalogue",
    "edition": "time-series",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/ons-uk-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "catalogue",
    "edition": "time-series",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("parseforge/ons-uk-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "catalogue",
  "edition": "time-series",
  "maxItems": 10
}' |
apify call parseforge/ons-uk-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=parseforge/ons-uk-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "ONS UK Statistics Beta API Scraper",
        "description": "Scrape the UK Office for National Statistics (ONS) Beta API. Pull the dataset catalogue, dataset-level metadata, editions, versions and CSV-style observations across themes including economy, population, labour market and inflation.",
        "version": "0.0",
        "x-build-id": "sglntNZaj64xL07v3"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/parseforge~ons-uk-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-parseforge-ons-uk-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/parseforge~ons-uk-scraper/runs": {
            "post": {
                "operationId": "runs-sync-parseforge-ons-uk-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/parseforge~ons-uk-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-parseforge-ons-uk-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "catalogue",
                            "dataset",
                            "observations",
                            "availableDimensions"
                        ],
                        "type": "string",
                        "description": "What to scrape from the official ONS UK catalogue: full dataset catalogue, single dataset metadata + editions, or actual observations from a specific version.",
                        "default": "catalogue"
                    },
                    "datasetId": {
                        "title": "Dataset ID",
                        "type": "string",
                        "description": "ONS dataset slug (e.g. cpih01, wellbeing-quarterly). Required for dataset and observations modes."
                    },
                    "datasetIds": {
                        "title": "Dataset IDs (batch lookup, dataset mode)",
                        "type": "array",
                        "description": "Array of ONS dataset slugs to fetch in one run (dataset mode). Takes precedence over single datasetId. Max 100 per call.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "edition": {
                        "title": "Edition",
                        "type": "string",
                        "description": "Edition slug (default: time-series). Used in observations mode.",
                        "default": "time-series"
                    },
                    "version": {
                        "title": "Version",
                        "type": "string",
                        "description": "Version number. Leave empty to use the latest version exposed by the dataset."
                    },
                    "dimensions": {
                        "title": "Dimension filters",
                        "type": "object",
                        "description": "Dimension wildcards used in observations mode, e.g. {\"geography\":\"K04000001\",\"time\":\"*\",\"aggregate\":\"cpih1dim1A0\"}. Use '*' for any."
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
