# OpenPrescribing NHS Spend Scraper (`parseforge/openprescribing-scraper`) Actor

Track NHS England prescribing spend by drug from OpenPrescribing. Search a drug or pass a BNF code, and get a monthly series of items dispensed, quantity, actual cost in pounds, and cost per item across five years. Useful for health policy research, pharma analysis, and budget tracking.

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

## Pricing

from $9.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/ad35ccc13ddd068b9d6cba33f323962e39aed5b2/banner.jpg?raw=true)

## 💊 OpenPrescribing NHS Spend Scraper

> 🚀 **Track NHS England drug spend month by month.** One search for "atorvastatin" returns five years of national spend, 4.3 million items a month at the peak.

> 🕒 **Last updated:** 2026-06-02 · **📊 13 fields** per row · 60 months of history · drug name or BNF code input

Pull NHS England prescribing spend from OpenPrescribing, the open analytics platform built on official prescribing data. Search a drug by name or pass a BNF code, and get a monthly series of items dispensed, quantity, actual cost in pounds, and cost per item.

**Coverage:** national NHS England prescribing for any BNF chemical, with the most recent 60 months of data per drug.

| 🎯 Target Audience | 💡 Primary Use Cases |
|---|---|
| Health policy researchers | Track spend and volume trends |
| Pharma analysts | Study market size by drug |
| NHS and ICB teams | Monitor prescribing budgets |
| Journalists and data scientists | Build prescribing datasets |

### 📋 What the OpenPrescribing NHS Spend Scraper does

- Resolves drug names to their NHS BNF chemical codes.
- Accepts exact BNF codes for precise pulls.
- Returns a monthly national spend series per drug.
- Reports items, quantity, actual cost, and a computed cost per item.
- Covers the most recent 60 months of data.
- Exports to CSV, Excel, JSON, XML, or via API.

### 🎬 Full Demo (_🚧 Coming soon_)

### ⚙️ Input

| Field | Type | Description |
|---|---|---|
| `searchTerms` | array | Drug or chemical names to search. |
| `bnfCodes` | array | Exact NHS BNF chemical codes. |
| `maxItems` | integer | Cap on rows returned. Free plan is limited to 10. Each row is one drug in one month. |

**Example 1: by drug name**
```json
{
  "searchTerms": ["atorvastatin", "metformin"],
  "maxItems": 120
}
````

**Example 2: by exact BNF code**

```json
{
  "searchTerms": [],
  "bnfCodes": ["0407010H0"],
  "maxItems": 60
}
```

> ⚠️ **Good to Know:** data is national NHS England spend per BNF chemical, with the latest 60 months available per drug. A drug name can map to more than one chemical across BNF sections, so each chemical is returned separately. The `searchTerm` field is empty for rows pulled from an exact BNF code.

### 📊 Output

Each record contains the following fields:

| Field | Description |
|---|---|
| 💊 `drugName` | Chemical name |
| 🔢 `bnfCode` | NHS BNF chemical code |
| 📂 `section` | BNF section |
| 🏛 `orgName` | Organisation (NHS England) |
| 📅 `date` | Month (first of month) |
| 📦 `items` | Items dispensed |
| 🔬 `quantity` | Total quantity |
| 💷 `actualCost` | Actual cost in pounds |
| 🧮 `costPerItem` | Cost per item in pounds |
| 🔗 `spendingUrl` | OpenPrescribing chemical page |
| 🔎 `searchTerm` | Query that surfaced this drug |
| 🕒 `scrapedAt` | Collection timestamp |
| ❌ `error` | Error message, null on success |

**Real sample records:**

```json
{
  "drugName": "Paracetamol",
  "bnfCode": "0407010H0",
  "section": "4.7: Analgesics",
  "orgName": "NHS England",
  "date": "2021-04-01",
  "items": 1364878,
  "quantity": 206674783,
  "actualCost": 6541946.78,
  "costPerItem": 4.79,
  "spendingUrl": "https://openprescribing.net/chemical/0407010H0/",
  "error": null
}
```

```json
{
  "drugName": "Atorvastatin",
  "bnfCode": "0212000B0",
  "section": "2.12: Lipid-regulating drugs",
  "orgName": "NHS England",
  "date": "2021-04-01",
  "items": 4330073,
  "quantity": 132374000,
  "actualCost": 7303071.63,
  "costPerItem": 1.69,
  "spendingUrl": "https://openprescribing.net/chemical/0212000B0/",
  "error": null
}
```

```json
{
  "drugName": "Atorvastatin",
  "bnfCode": "0212000B0",
  "section": "2.12: Lipid-regulating drugs",
  "orgName": "NHS England",
  "date": "2021-10-01",
  "items": 4322548,
  "actualCost": 5911025.92,
  "costPerItem": 1.37,
  "spendingUrl": "https://openprescribing.net/chemical/0212000B0/",
  "error": null
}
```

### ✨ Why choose this Actor

- **Name or code.** Search by drug name or pull an exact BNF chemical.
- **Ready trends.** A clean monthly series, one row per month.
- **Computed cost per item.** Spot price changes at a glance.
- **Official basis.** Built on NHS England prescribing data via OpenPrescribing.
- **Ready to export.** CSV, Excel, JSON, XML, or API, with a clean table view.

### 📈 How it compares to alternatives

| | OpenPrescribing NHS Spend Scraper | Manual API calls | Generic web scrapers |
|---|---|---|---|
| Drug name to code resolution | ✅ | ⚠️ Manual | ❌ |
| Monthly national series | ✅ | ⚠️ | ❌ |
| Computed cost per item | ✅ | ❌ | ❌ |
| Multi-drug runs | ✅ | ⚠️ | ⚠️ |
| Export to CSV/Excel/JSON/XML | ✅ | ❌ | ⚠️ |

### 🚀 How to use

1. Create a free Apify account using [this sign-up link](https://console.apify.com/sign-up?fpr=vmoqkp).
2. Open the OpenPrescribing NHS Spend Scraper.
3. Enter `searchTerms` or `bnfCodes`, and set `maxItems`.
4. Click **Start** and watch the dataset fill in real time.
5. Export your results as CSV, Excel, JSON, or XML, or pull them via API.

### 💼 Business use cases

**📊 Market sizing**
| Goal | How |
|---|---|
| Size a drug market | Sum actual cost across months |
| Compare volumes | Rank by items dispensed |

**💷 Budget and policy**
| Goal | How |
|---|---|
| Track spend | Follow the monthly cost series |
| Spot price moves | Watch cost per item |

**🔬 Research**
| Goal | How |
|---|---|
| Study uptake | Compare items over time |
| Build datasets | Pull many drugs at once |

**📰 Reporting**
| Goal | How |
|---|---|
| Tell a story | Chart spend trends |
| Fact check | Cite official prescribing data |

### 🔌 Automating OpenPrescribing NHS Spend Scraper

Connect this Actor to your stack with Apify integrations: **Make**, **Zapier**, **Slack**, **Airbyte**, **GitHub**, and **Google Drive**. Schedule runs and push fresh prescribing data into spreadsheets, databases, or alerts.

### 🌟 Beyond business use cases

- **Research:** study NHS prescribing patterns over time.
- **Personal:** explore how much the NHS spends on common drugs.
- **Non-profit:** support health transparency projects.
- **Experimentation:** build healthcare analytics dashboards.

### 🤖 Ask an AI assistant

Paste your dataset into [ChatGPT](https://chat.openai.com), [Claude](https://claude.ai), [Perplexity](https://www.perplexity.ai), or [Copilot](https://copilot.microsoft.com) and ask for the fastest growing drugs, biggest spend, or cost per item trends.

### ❓ Frequently Asked Questions

**1. Do I need an API key?**
No. The Actor uses the open OpenPrescribing data.

**2. What spend is covered?**
National NHS England prescribing spend per BNF chemical.

**3. How much history is available?**
The most recent 60 months per drug.

**4. How do I target an exact drug?**
Pass its BNF chemical code in `bnfCodes`.

**5. Why does one name return several rows?**
A name can map to more than one BNF chemical across sections.

**6. What is cost per item?**
Actual cost divided by items dispensed, in pounds.

**7. What export formats are supported?**
CSV, Excel, JSON, XML, and API.

**8. Can I pull several drugs at once?**
Yes. Add multiple search terms or BNF codes.

**9. Can I run it on a schedule?**
Yes, with Apify Schedules and integrations.

**10. Is there a free option?**
Yes. Free runs are limited to 10 items as a preview. Paid plans unlock up to 1,000,000.

### 🔌 Integrate with any app

Use the Apify API, webhooks, and 5,000-plus integrations to push OpenPrescribing data into Make, Zapier, Google Sheets, Airtable, databases, and more.

### 🔗 Recommended Actors

- [openFDA Drug Labels Scraper](https://apify.com/parseforge/openfda-drug-labels-scraper)
- [DailyMed FDA Labels Scraper](https://apify.com/parseforge/dailymed-fda-labels-scraper)
- [NADAC Drug Prices Scraper](https://apify.com/parseforge/nadac-drug-prices-scraper)
- [UK CQC Care Quality Scraper](https://apify.com/parseforge/uk-cqc-care-quality-scraper)
- [EMA Medicines Scraper](https://apify.com/parseforge/ema-medicines-scraper)

> 💡 **Pro Tip:** browse the complete [ParseForge collection](https://apify.com/parseforge).

**🆘 Need Help?** [Open our contact form](https://tally.so/r/BzdKgA)

> **⚠️ Disclaimer:** independent tool, not affiliated with OpenPrescribing, the Bennett Institute, or the NHS. Data is provided by the OpenPrescribing open data platform.

# Actor input Schema

## `searchTerms` (type: `array`):

Drug or chemical names to search (e.g. "ibuprofen", "atorvastatin"). Each resolves to its NHS BNF chemicals.

## `bnfCodes` (type: `array`):

Exact NHS BNF chemical codes (e.g. "0407010H0" for Paracetamol).

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

Free users: limited to 10 items (preview). Paid users: optional, max 1,000,000. Each row is one drug in one month.

## Actor input object example

```json
{
  "searchTerms": [
    "atorvastatin"
  ],
  "maxItems": 10
}
```

# Actor output Schema

## `results` (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 = {
    "searchTerms": [
        "atorvastatin"
    ],
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/openprescribing-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 = {
    "searchTerms": ["atorvastatin"],
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("parseforge/openprescribing-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 '{
  "searchTerms": [
    "atorvastatin"
  ],
  "maxItems": 10
}' |
apify call parseforge/openprescribing-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "OpenPrescribing NHS Spend Scraper",
        "description": "Track NHS England prescribing spend by drug from OpenPrescribing. Search a drug or pass a BNF code, and get a monthly series of items dispensed, quantity, actual cost in pounds, and cost per item across five years. Useful for health policy research, pharma analysis, and budget tracking.",
        "version": "0.1",
        "x-build-id": "2KSTw6Z2HYoYMs3a8"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/parseforge~openprescribing-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-parseforge-openprescribing-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~openprescribing-scraper/runs": {
            "post": {
                "operationId": "runs-sync-parseforge-openprescribing-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~openprescribing-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-parseforge-openprescribing-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": {
                    "searchTerms": {
                        "title": "Drug search terms",
                        "type": "array",
                        "description": "Drug or chemical names to search (e.g. \"ibuprofen\", \"atorvastatin\"). Each resolves to its NHS BNF chemicals.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "bnfCodes": {
                        "title": "BNF codes",
                        "type": "array",
                        "description": "Exact NHS BNF chemical codes (e.g. \"0407010H0\" for Paracetamol).",
                        "items": {
                            "type": "string"
                        }
                    },
                    "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. Each row is one drug in one month."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
