BYTETOOLS

NHS Scotland Open Data API

Free NHS Scotland open data API with no key: hospital activity, waiting times, prescribing and health board reference data through the standard CKAN interface. Tested example included.

No API key requiredHTTPSFree tier

Endpoint tested and returned HTTP 200 on 2026-08-21

What is the NHS Scotland Open Data API?

The NHS Scotland open data portal exposes a free, key-free CKAN API published by Public Health Scotland. It provides around a hundred curated datasets covering hospital activity, waiting times, prescribing, workforce, mortality and the geographic reference codes that tie NHS statistics together.

National health statistics are usually scattered across PDF publications and spreadsheets. Public Health Scotland instead publishes its official statistics as machine-readable datasets on a CKAN portal, complete with the reference lookups — health board codes, hospital codes, deprivation quintiles — that make the numbers joinable. That reference layer is what turns a collection of CSVs into something you can actually analyse.

The catalogue is deliberately curated rather than exhaustive: roughly a hundred datasets, each carrying a `nhs_statistics_designation` marking it as Official Statistics or National Statistics under the UK Code of Practice. That designation is worth surfacing in any application built on it, because it tells a reader how the figures were produced and quality-assured. Being CKAN, the query interface is identical to Ireland's, Australia's and Finland's portals, so one client covers all of them.

Quick facts

Base URL
https://www.opendata.nhs.scot/api/3/action
Authentication
No API key for read operations. Only publishing requires an account.
Rate limit
No published limit. Reasonable paging expected.
Pricing
Free. Open Government Licence v3.0, which permits commercial reuse with attribution.
CORS
Not enabled — call it from your server
Official docs
Read the docs

How to use the NHS Scotland Open Data API

Every request below was executed against the live API on 2026-08-21, and the response shown is the real body it returned — not an illustration.

1. Search NHS Scotland datasets

GET https://www.opendata.nhs.scot/api/3/action/package_search?rows=1

curl
curl 'https://www.opendata.nhs.scot/api/3/action/package_search?rows=1'
JavaScript (fetch)
const res = await fetch("https://www.opendata.nhs.scot/api/3/action/package_search?rows=1");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);
Python (requests)
import requests

res = requests.get("https://www.opendata.nhs.scot/api/3/action/package_search?rows=1", timeout=20)
res.raise_for_status()
print(res.json())
Response — HTTP 200 (truncated)
{
  "help": "https://www.opendata.nhs.scot/api/3/action/help_show?name=package_search",
  "success": true,
  "result": {
    "count": 104,
    "sort": "score desc, metadata_modified desc",
    "facets": {},
    "results": [
      {
        "nhs_language": "English",
        "owner_org": "2c2f8c3a-107a-40f5-b9ea-eb29d5b13790",
        "maintainer": "Public Health Scotland",
        "relationships_as_object": [],
        "nhs_statistics_designation": "Official Statistics",
        "private": false,
        "maintainer_email": "PHS.Covid19Data&Analytics@phs.scot",
        "num_tags": 0,
        "nhs_concepts": "Number of new laboratory positive test results expressed as a rate per 100,000 Scottish population (mid-year estimates). Influenza (flu) is a contagious respiratory illness caused by influenza viruses. There are two main types of influenza virus: Types A and B. The influenza A and B viruses that routinely spread in people (human influenza viruses) are responsible for seasonal flu epidemics each year. Current subtypes of influenza A viruses routinely found in people are influenza A(H1N1) and influenza A(H3N2) viruses. Currently circulating influenza B viruses belong to one of two lineages: B/Yamagata and B/Victoria.",
        "nhs_subject": "Acute Respiratory Infection, Influenza, COVID-19",
        "id": "49dc2d88-1cb0-4420-a5ea-d1bbada62fb2",
        "metadata_created": "2023-11-23T08:48:35.190837",
        "nhs_disclosure": "The PHS Statistical Disclosure Protocol is followed.",
        "metadata_modified": "2026-08-20T08:41:02.269432",
        "author": "Public Healt

Parameters

ParameterTypeRequiredDescription
qqueryOptionalFree-text Solr query across dataset titles, descriptions and tags. waiting times
rowsqueryOptionalHow many datasets to return. Defaults to 20. 1
startqueryOptionalPagination offset. 0
fqqueryOptionalFilter query, for example by organisation or resource format. res_format:CSV
(datastore_search)actionOptionalA separate CKAN action queries the rows INSIDE a dataset rather than searching the catalogue.

Response fields

successboolean
Whether the CKAN action succeeded. Check it — CKAN returns HTTP 200 with `success: false` on validation errors.
result.countinteger
Total datasets matching the query. Around 104 in the whole catalogue, which is curated rather than exhaustive.
results[].title / notesstring
Dataset title and description.
results[].maintainerstring
Publishing team, usually Public Health Scotland.
results[].nhs_statistics_designationstring
`Official Statistics` or `National Statistics` under the UK Code of Practice — meaningful provenance worth displaying.
results[].resourcesarray
The downloadable files, each with a format and a direct URL. Most are CSV.
results[].resources[].idstring
Resource id, which is the key for the `datastore_search` action that queries rows directly.

What you can build with the NHS Scotland Open Data API

  • Analyse Scottish hospital waiting times or activity trends
  • Build a public health dashboard from official statistics
  • Join NHS data to geographic areas using the published reference lookups
  • Query dataset rows directly through the datastore rather than downloading CSVs

Common errors and how to fix them

HTTP 200 with success false

CKAN rejected the parameters.

Fix: Read `error.message` in the body — CKAN never signals validation failures through the status code.

Dataset found but no rows

You searched the catalogue, not the data.

Fix: `package_search` finds datasets; `datastore_search` with a resource id queries the rows inside one. They are different actions.

400

Malformed Solr syntax in `q` or `fq`.

Fix: Unbalanced quotes and stray colons break the parser. Test the query in the portal's own search first.

NHS Scotland Open Data API — frequently asked questions

Is the NHS Scotland open data API free?

Yes, all read operations are free with no API key. The data is published under the Open Government Licence v3.0, which permits commercial reuse with attribution.

How do I query the data inside a dataset?

Use the `datastore_search` action with a resource id rather than `package_search`, which only searches the catalogue. That distinction catches out most people on their first CKAN integration.

What does the statistics designation mean?

It marks a dataset as Official Statistics or National Statistics under the UK Code of Practice for Statistics, which tells a reader how the figures were produced and quality-assured. It is worth surfacing wherever you display the numbers.

Does it use the same API as other government portals?

Yes, it runs CKAN, the same platform as Ireland's, Australia's and Finland's national portals. The actions and parameters are identical, so one client works against all of them with only the base URL changing.

Tools that pair with this API

NHS Scotland Open Data is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-21; always check the official documentation before relying on this API in production, as terms and limits can change.