# Uk Carbon Intensity Scraper (`b2b_lead_generation/uk-carbon-intensity-scraper`) Actor

Extract Great Britain's half-hourly national grid carbon intensity and regional power generation mix. Track CO2 forecasts, actuals, and fuel percentages, then download structured data directly as CSV, JSON, or Excel.

- **URL**: https://apify.com/b2b_lead_generation/uk-carbon-intensity-scraper.md
- **Developed by:** [B2B Lead Generation](https://apify.com/b2b_lead_generation) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## UK Carbon Intensity Scraper: National and Regional Grid

<p align="center">
  <img src="https://imgur.com/XpHzR1H.png" alt="UK Carbon Intensity Scraper" style="max-width:100%; border-radius:14px; width:680px;" />
</p>

The UK carbon intensity scraper exports Great Britain's half-hourly grid carbon intensity and regional generation mix. Export to CSV, JSON, or Excel whenever you want the same half-hours saved for analysis.

A default run asks for the current national half-hour. Set both `from` and `to` when you want a longer national series. Regional mode asks for one distribution region, using IDs 1 through 17.

### Use Cases

- **Grid reporting:** Archive national gCO2/kWh, including forecast and actual values, for any date range.
- **Regional mix:** Pull a specific DNO region, including the intensity band and fuel percentage breakdown.
- **Forecast checks:** Keep the index label (from "very low" through "very high") alongside numeric values.
- **Scheduled exports:** Set up automated runs to download fresh dataset updates as CSV, JSON, or Excel.
- **Research notes:** Reference carbon footprint data directly for academic, commercial, or personal sustainability studies.

### Extracted Data Format

Intensity mode writes one row per half-hour, while regional mode writes one row per region. Every row includes `scrapedAt`. National rows do not include a region ID. The half-hour object stays inside `data`, and `forecast`, `actual`, and the `index` are copied to top-level fields so CSV exports remain clean and readable.

```json
{
  "regionid": 1,
  "dnoregion": "Scottish Hydro Electric Power Distribution",
  "shortname": "North Scotland",
  "data": [
    {
      "from": "2026-10-11T20:30Z",
      "to": "2026-10-11T21:00Z",
      "intensity": {
        "forecast": 0,
        "index": "very low"
      },
      "generationmix": [
        {"fuel": "biomass", "perc": 0},
        {"fuel": "coal", "perc": 0}
      ]
    }
  ],
  "scrapedAt": "2026-10-12T00:00:00+00:00"
}

```

#### Data Fields

| Field | Type | Description |
| --- | --- | --- |
| `regionid` | integer | Region identifier. Omitted on national rows. |
| `dnoregion` | string | Full DNO region name. |
| `shortname` | string | Short region name (e.g., Region 1 is North Scotland). |
| `data` | array | Source periods, including intensity and generation mix. |
| `periodFrom` | string | National half-hour start time. |
| `periodTo` | string | National half-hour end time. |
| `forecast` | number | Forecast gCO2/kWh value. |
| `actual` | number | Actual gCO2/kWh value. |
| `intensityIndex` | string | Carbon intensity band (e.g., moderate, very low). |
| `scrapedAt` | string | UTC timestamp when the record was collected. |
| `error` | string | Detailed message captured if an issue occurs. |

### Input Options

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | string | `intensity` | Set to `intensity` for national series, or `regional` for regional mix. |
| `scope` | string | `national` | Set to `regional` to target regional details. |
| `regionId` | integer | `1` | Region ID (1 to 17). Region 1 is North Scotland. |
| `from` | string | *empty* | Range start timestamp (ISO 8601 UTC). Required for national range queries. |
| `to` | string | *empty* | Range end timestamp (ISO 8601 UTC). Required for national range queries. |
| `maxItems` | integer | `100` | Maximum number of rows to save (hard cap at 1000). |
| `timeoutSecs` | integer | `300` | Overall execution limit in seconds. |
| `requestTimeoutSecs` | integer | `30` | Per-request timeout limit in seconds. |

#### Example Inputs

**National Intensity:**

```json
{
  "mode": "intensity",
  "scope": "national",
  "from": "2026-10-01T00:00Z",
  "to": "2026-10-02T00:00Z",
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30
}

```

**Regional Mix:**

```json
{
  "mode": "regional",
  "regionId": 1,
  "maxItems": 100
}

```

### How Limits and Pagination Work

National ranges are automatically processed in 14-day chunks to match maximum allowed single-request spans. Calls are paced gently to keep operations running smoothly, stopping as soon as your requested `maxItems` limit is reached.

If temporary connection glitches or server busy signals happen, automatic retries step in with sensible wait pauses before trying again. Bad inputs (like invalid region IDs) write a clear error row into your dataset without crashing the entire run. Duplicate records and identical region updates are automatically removed so your data stays clean.

### FAQ

**How many records can I save in one go?**

The default limit is set to 100 rows, with a maximum cap of 1,000. Since a full day of national half-hourly periods comes out to 48 rows, a 1-day or 2-day historical extract fits comfortably within default settings.

**What happens if I enter an invalid Region ID?**

The actor records a single error row describing the issue and continues gracefully without failing your task.

**Can I export my data to CSV or Excel?**

Yes. Once your run completes, you can download your full dataset directly in JSON, CSV, or Excel formats.

**Can I request historical dates for regional mix data?**

Regional fetches pull the latest half-hourly figures available for your selected region ID. If you need historical carbon intensity trends over time, use the national mode with `from` and `to` date parameters.

***

### Trademark Notice

UK Carbon Intensity and related names, logos, and trademarks belong to their respective owners. Reference to these names is strictly for identification purposes and does not imply sponsorship, endorsement, or formal partnership.

### Disclaimer & Legal Guidelines

This scraper is an independent data extraction tool. Users are responsible for complying with applicable terms of use, data protection guidelines, and attribution requirements when utilizing exported datasets.

#### Is Data Extraction Legal?

This tool collects publicly accessible carbon footprint data without bypassing access controls. Extracting public figures is standard practice, but consider these guidelines when working with extracted data:

- **Personal Data:** This tool purely handles environmental grid measurements and contains no personal data or personal identifiers.
- **Copyright & Licensing:** Always cite carbon grid figures properly if publishing findings, reports, or dashboards publicly.
- **Usage Rules:** Be mindful of request rates and avoid overloading data infrastructure.
- **Legal Advice:** Information provided here serves as practical guidance, not formal legal advice.

# Actor input Schema

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

intensity returns half-hourly national carbon intensity for Great Britain. regional returns one distribution region, including its intensity index and generation mix.

## `scope` (type: `string`):

national keeps the GB-wide intensity series. regional switches the run to the regional endpoint even when mode is intensity. Allowed values are national and regional.

## `regionId` (type: `integer`):

Distribution region id used for regional mode or regional scope. Valid ids are 1 to 17. 1 is North Scotland (Scottish Hydro Electric Power Distribution). Other ids are sent as-is so a bad id comes back as an error row.

## `from` (type: `string`):

Range start in ISO 8601 UTC, for example 2026-10-01T00:00Z. Leave empty, together with to, to fetch the current national half-hour. A range needs both from and to. Ranges apply to national intensity only and are split into 14-day windows.

## `to` (type: `string`):

Range end in ISO 8601 UTC, for example 2026-10-02T00:00Z. Leave empty, together with from, to fetch the current national half-hour. The end is exclusive of the next window boundary and must be later than from.

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

Maximum dataset rows for this run, including error rows. The actor stops at this cap. Values above 1000 are clamped to 1000.

## `timeoutSecs` (type: `integer`):

Stop starting new Carbon Intensity requests after this many seconds. Does not replace the Apify run timeout.

## `requestTimeoutSecs` (type: `integer`):

Seconds to wait for a single Carbon Intensity HTTP response before retrying.

## `proxyConfiguration` (type: `object`):

Optional proxy for Carbon Intensity requests. The default sends traffic directly, with no Apify Proxy. The public API does not need a proxy, and proxies must not be used to get around rate limits.

## Actor input object example

```json
{
  "mode": "intensity",
  "scope": "national",
  "regionId": 1,
  "from": "2026-10-01T00:00Z",
  "to": "2026-10-02T00:00Z",
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `datasetUrl` (type: `string`):

No description

# 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": "intensity",
    "scope": "national",
    "regionId": 1,
    "maxItems": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_lead_generation/uk-carbon-intensity-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": "intensity",
    "scope": "national",
    "regionId": 1,
    "maxItems": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("b2b_lead_generation/uk-carbon-intensity-scraper").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 '{
  "mode": "intensity",
  "scope": "national",
  "regionId": 1,
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call b2b_lead_generation/uk-carbon-intensity-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b_lead_generation/uk-carbon-intensity-scraper"
        }
    }
}
```

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/8TGKhgm71Wi3D2gb8/builds/He55ib1H9LjjfQLQD/openapi.json
