bolster.data_sources.nisra.pxstat

NISRA PxStat API client.

Provides access to the NISRA open data API at https://data.nisra.gov.uk/, powered by the PxStat platform (https://github.com/CSOIreland/PxStat).

The API is publicly accessible without authentication and has no observed rate limits, making it a more reliable alternative to scraping Excel files from publication pages.

API endpoint pattern:

GET https://ws-data.nisra.gov.uk/public/api.restful/
    PxStat.Data.Cube_API.ReadDataset/{MATRIX}/CSV/1.0/en

CSV responses include a UTF-8 BOM — always decode with utf-8-sig.

Example:

>>> from bolster.data_sources.nisra.pxstat import read_dataset
>>> df = read_dataset("WDTHS")
>>> "VALUE" in df.columns
True

Attributes

logger

Exceptions

PxStatError

Raised when the PxStat API returns an unexpected response.

Functions

read_dataset(matrix[, timeout])

Fetch a dataset from the NISRA PxStat API as a DataFrame.

Module Contents

bolster.data_sources.nisra.pxstat.logger[source]
exception bolster.data_sources.nisra.pxstat.PxStatError[source]

Bases: Exception

Raised when the PxStat API returns an unexpected response.

Initialize self. See help(type(self)) for accurate signature.

bolster.data_sources.nisra.pxstat.read_dataset(matrix, timeout=30)[source]

Fetch a dataset from the NISRA PxStat API as a DataFrame.

Parameters:
  • matrix (str) – Dataset matrix code (e.g. "WDTHS" for weekly deaths).

  • timeout (int) – HTTP request timeout in seconds.

Returns:

DataFrame with raw API columns. The VALUE column contains the numeric values; all other columns are dimension labels and codes.

Raises:

PxStatError – If the API returns a non-200 response.

Return type:

pandas.DataFrame

Example

>>> df = read_dataset("WDTHS")
>>> "VALUE" in df.columns
True