# 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, 93.1% runs succeeded, 0 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 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

![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.

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.

### 📊 Data fields

Each record includes: `actualCost`, `bnfCode`, `costPerItem`, `date`, `drugName`, `items`, `quantity`, `results`, `scrapedAt`, `section`, `spendingUrl`. These field names come straight from the actor's dataset schema, so what you see here is what lands in your dataset.

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

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

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

### 🆘 Need Help?

If you hit a bug, have questions about setup, or need a scraper we haven't built yet, open our [contact form](https://tally.so/r/BzdKgA) or write to parseforge@protonmail.com. We also take on paid custom data projects.

For faster answers, join our [Discord](https://parseforge.co/discord). It's the best place to get support and suggest new actors.

# 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

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