# UK Open Data Studio — Gov Data Joins (`subimpact/uk-open-data-studio`) Actor

Value layer on the UK ONS open data API: 6 join presets (GDP, Inflation, Labour, Population, Trade, Housing) + custom joins + raw extraction, CSV/JSON/XLSX, AI-ready output, OGL v3 attribution.

- **URL**: https://apify.com/subimpact/uk-open-data-studio.md
- **Developed by:** [subimpact](https://apify.com/subimpact) (community)
- **Categories:** AI, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 joined pulls

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## UK Open Data Studio — Gov Data Joins 🇬🇧

Value layer on the UK's official open data. Join cross-dataset indicators into clean, AI-ready tables — or pull raw datasets by ID.

**Source:** [ONS beta API](https://api.beta.ons.gov.uk/v1) (Office for National Statistics open data API, keyless). The [data.gov.uk](https://data.gov.uk) CKAN catalogue is a metadata directory — its datastore API returns 403 and resources are HTML links — so the value layer pulls structured time series directly from the ONS API.

**Licence:** ONS data is published under the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/) (crown copyright). Years are native CE.

### Features

#### Studio mode (value layer) — $0.02/joined-pull

Six cross-dataset join presets, delivered as CSV / JSON / XLSX with an AI-ready package (JSON Schema + data dictionary + sample rows) and attribution sidecar:

- **T1 GDP & Economy by Year** — annual GDP index for England (chained volume measure, all industries)
- **T2 Inflation by Year** — CPIH all-items index (overall), December values
- **T3 Labour Market by Year** — employment × unemployment × economic inactivity rates (16+, seasonally adjusted)
- **T4 Population by Year** — UK mid-year population estimates (total, all ages)
- **T5 Trade by Year** — UK total exports and imports (whole world, monthly means)
- **T6 Housing by Year** — Index of Private Housing Rental Prices (UK, December values)

Custom joins: bring your own ONS dataset IDs, key columns, join type (inner/left), aggregation (none/sum/mean), and dimension filters.

#### Extract mode (raw data pull) — $0.01/extract-pull

Pull 1-5 ONS datasets raw by ID (e.g. `cpih01`, `labour-market`, `regional-gdp-by-year`), no join, no reshape. Per-dataset files + manifest + attribution.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| mode | select | studio | studio = value layer, extract = raw pull |
| preset | select | T1 | T1-T6 or custom |
| datasetIds | stringList | — | extract mode: 1-5 IDs |
| customDatasets | stringList | — | custom join: 2-6 IDs |
| customKey | stringList | \[year] | join keys ('year' auto-extracts from ONS Time labels) |
| customJoinType | select | inner | inner / left |
| customParams | textfield | — | JSON dimension filters |
| customAgg | select | none | none / sum / mean |
| format | select | json | json / csv / xlsx |
| webhookUrl | textfield | — | optional POST target |
| aiReady | checkbox | true | AI-ready package |
| includeAttribution | checkbox | true | attribution sidecar |

### Output

- **Dataset:** one summary record per run (mode, preset, rows, format, files, year range, run URL) — rendered as a table in the Output tab.
- **Key-value store:** the joined/extracted file, `*_verification.json`, `*_attribution.json`, `*_ai_ready.json` (studio) or per-dataset files + `extract_manifest.json` (extract).

### Example

```bash
## Studio: GDP & Economy preset, CSV
curl -X POST "https://api.apify.com/v2/acts/<ACTOR_ID>/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"preset":"T1","format":"csv"}'

## Extract: pull CPIH + labour market raw
curl -X POST "https://api.apify.com/v2/acts/<ACTOR_ID>/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode":"extract","datasetIds":["cpih01","labour-market"],"format":"json"}'
```

### Notes

- The ONS beta API is public and keyless; no API key required.
- The API is a beta service — endpoints may change.
- The data.gov.uk CKAN datastore is disabled (403), so presets use the ONS API only.

# Actor input Schema

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

studio = value layer (presets, joins, AI-ready package). extract = raw data pull of 1-5 ONS datasets by ID (cheaper per-pull event).

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

For mode=extract: list of ONS dataset ids (e.g. cpih01, labour-market, regional-gdp-by-year) to pull raw (1-5). Leave empty to use studio mode.

## `preset` (type: `string`):

Join bundle. T1 = GDP & Economy by Year. T2 = Inflation by Year. T3 = Labour Market by Year. T4 = Population by Year. T5 = Trade by Year. T6 = Housing by Year. custom = bring your own ONS dataset ids.

## `customDatasets` (type: `array`):

For preset=custom: list of ONS dataset ids to join (2-6). Leave empty to use a preset.

## `customKey` (type: `array`):

For preset=custom: key parts to join on. Use 'year' (auto-extracted from ONS Time labels) or raw field names. All datasets must share these keys.

## `customJoinType` (type: `string`):

inner keeps only keys present in every dataset; left keeps all keys from the first dataset.

## `customParams` (type: `string`):

For preset=custom: JSON object of extra ONS dimension filters applied to every dataset, e.g. {"dims": {"geography": "K02000001"}}.

## `customAgg` (type: `string`):

none = keep raw rows (last value per key). sum = aggregate numeric values per key. mean = average numeric values per key.

## `format` (type: `string`):

File format delivered to the key-value store (dataset records are always JSON).

## `webhookUrl` (type: `string`):

POST the result file to this URL after the run (3 retries with backoff). Leave empty to skip.

## `aiReady` (type: `boolean`):

Also emit JSON Schema + data dictionary + sample rows for LLM/RAG ingestion.

## `includeAttribution` (type: `boolean`):

Attach source/licence metadata sidecar to every output (Open Government Licence v3.0).

## Actor input object example

```json
{
  "mode": "studio",
  "preset": "T1",
  "customKey": [
    "year"
  ],
  "customJoinType": "inner",
  "customAgg": "none",
  "format": "json",
  "aiReady": true,
  "includeAttribution": true
}
```

# Actor output Schema

## `runSummary` (type: `string`):

One summary record per run: mode, preset, row count, format, files, year range.

## `joinedData` (type: `string`):

The joined dataset file (CSV/JSON/XLSX) in the default key-value store.

## `extractedData` (type: `string`):

Raw dataset file(s) (CSV/JSON/XLSX) in the default key-value store.

## `aiReadyPackage` (type: `string`):

JSON Schema + data dictionary + sample rows for LLM/RAG ingestion.

## `attribution` (type: `string`):

Source and licence metadata (Open Data Common / CC).

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("subimpact/uk-open-data-studio").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("subimpact/uk-open-data-studio").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call subimpact/uk-open-data-studio --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,subimpact/uk-open-data-studio"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ACwB7aK7UtCsbiotI/builds/oG7xNw1bct1UKedZH/openapi.json
