Python client for UK Power Networks Open Data
Project description
ukpyn
ukpyn is the official Python client for UK Power Networks Open Data Portal. It provides simple, ergonomic access to distribution network data to support energy sector analysis and decarbonisation efforts.
This README is intentionally concise for PyPI. Full guides and reference pages are published via GitHub Pages docs.
Documentation
- Docs site (GitHub Pages): https://ukpn-dso.github.io/ukpyn/
- Tutorial notebooks: tutorials/
- API source: src/ukpyn/
- Changelog: CHANGELOG.md
Mission
ukpyn is built for accessibility to UK Power Networks open data:
- If you are new to coding: start with clear defaults, copy-paste examples, and tutorials.
- If you are experienced: use typed APIs, async workflows, exports, and low-level client control.
The package is designed to reduce friction without hiding power.
Features
- Simple orchestrator-based API - Access data by category (LTDS, flexibility, GIS, powerflow, etc.)
- Beginner-friendly defaults - Useful defaults for common queries, then optional filtering
- Both sync and async support - Use whichever fits your workflow
- Export to multiple formats - CSV, JSON, Excel, GeoJSON, Parquet, and more
- Jupyter notebook friendly - Works in notebooks and scripts
- Type hints throughout - Full IDE support with autocompletion
Installation
Recommended workflow: uv + your preferred environment
1) Create and activate an environment
Option A: conda
# Create and activate a Python 3.11 environment
conda create -n ukpyn python=3.11 -y
conda activate ukpyn
Option B: venv
# Create a virtual environment
python -m venv .venv
# Activate on macOS / Linux
source .venv/bin/activate
# Activate on Windows PowerShell
.venv\Scripts\Activate.ps1
2) Install uv
pip install uv
3) Install from this repository
# Clone and enter the repository (if you haven't already)
git clone https://github.com/UKPN-DSO/ukpyn.git
cd ukpyn
# Recommended: install using the lockfile
uv sync
Alternative uv pip installs:
# Editable install (base)
uv pip install -e .
# Editable install with dev tools
uv pip install -e ".[dev]"
# Editable install with all optional extras
uv pip install -e ".[all]"
Or install from PyPI with extras:
uv pip install ukpyn
uv pip install "ukpyn[dev]"
uv pip install "ukpyn[optional]"
uv pip install "ukpyn[all]"
Shell note: use double quotes for extras in PowerShell and bash. In Windows CMD, prefer uv pip install -e .[all].
Quick Start
1. Get an API key
- Create an account at UK Power Networks Open Data Portal
- Go to your profile and navigate to API keys
- Generate a new key
2. Set up your API key
Create a .env file in your project root:
UKPN_API_KEY=your_api_key_here
Or set it as an environment variable:
# macOS / Linux
export UKPN_API_KEY=your_api_key_here
# Windows PowerShell
$env:UKPN_API_KEY="your_api_key_here"
# Windows CMD
set UKPN_API_KEY=your_api_key_here
3. Start using ukpyn
Beginner path (first working call)
from ukpyn import ltds
# Fetch LTDS Table 3A with one filter
table_3a = ltds.get_table_3a(licence_area="EPN")
print(f"Rows returned: {len(table_3a.records)}")
Advanced path (multi-domain workflow)
from ukpyn import ltds, flexibility, gis, powerflow, curtailment
# Get LTDS Table 3A (observed peak demand at primary substations)
table_3a = ltds.get_table_3a(licence_area='Eastern Power Networks (EPN)')
# Get flexibility dispatch events
dispatches = flexibility.get_dispatches(start_date='2024-01-01')
# Get primary substation locations
substations = gis.get_primary_substations(licence_area='SPN')
# Get 132kV circuit time series
circuits = powerflow.get_circuit_timeseries(voltage='132kv', granularity='half_hourly')
# Get curtailment events
events = curtailment.get_events(start_date='2024-01-01')
Learning Paths
Note: To run the tutorials, install the full set of dependencies with
uv pip install "ukpyn[all]"(orpip install "ukpyn[all]").
- New to Python or APIs? Start with 01-getting-started, then 02-fetching-data.
- Comfortable with Python? Use 03-analysis-patterns and the docs site.
- Power users? Use async APIs and low-level client patterns documented in GitHub Pages docs.
Supported Domains
ukpyn provides themed orchestrators for:
- LTDS
- DFES
- DNOA
- Network
- Flexibility
- Curtailment
- DERS (with
resourcescompatibility alias) - GIS
- Powerflow
See full API usage patterns in the docs site: https://ukpn-dso.github.io/ukpyn/
Licence Areas
UK Power Networks operates three distribution licence areas:
- EPN - Eastern Power Networks (East of England)
- LPN - London Power Networks (Greater London)
- SPN - South Eastern Power Networks (South East England)
Many datasets can be filtered by licence area using the licence_area parameter.
Contributing
We welcome contributions from beginners and experienced developers.
See Contributing Guidelines for full details.
- Found a bug or have a question? Please open an issue — it helps us improve ukpyn for everyone.
- Have ideas for better utilities? Our
ukpyn.utilsmodule provides time series, statistical, and powerflow helpers — if you think we're missing something or could improve what's there, tell us in an issue. Community input shapes what we build next. - Open a pull request with focused changes and tests.
- If you are new to open source, small documentation improvements are a great first contribution.
Development Setup
# Clone the repository
git clone https://github.com/UKPN-DSO/ukpyn.git
cd ukpyn
# Install development dependencies
pip install ukpyn[dev]
# (Optional) install full optional feature set as well
pip install ukpyn[optional]
# Install dependencies with uv
uv sync
# Run tests
pytest
# Run linter
ruff check .
# Fix linting issues
ruff check --fix .
# Run pre-commit hooks
pre-commit run --all-files
Git Workflow
main- Protected branch for releases onlydev- Integration branch for developmentfeature/*- Feature branches for all work
Automated Registry Triage
- Daily registry audit runs via GitHub Actions to detect new unmanaged ODP datasets.
- When new unmanaged datasets are found, automation opens a triage issue assigned to
copilot. - The issue includes standardized tasks: decide orchestrator/registry placement, implement support, add a tutorial example, and open a PR into
devwith maintainers assigned for review.
Security
Please see SECURITY.md for our security policy.
Important: Never commit API keys or .env files to version control.
Acknowledgements
The vision for ukpyn as an accessible Python interface for UK Power Networks open data, along with the value proposition and initial scope, was developed with consultation from Dr Daniel Donaldson, Electronic, Electrical and Systems Engineering, University of Birmingham, Birmingham, United Kingdom.
License
This project is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0) - see the LICENSE file for details.
Redistributions and derivative works should retain attribution notices, including the NOTICE file, to acknowledge UK Power Networks Distribution System Operator.
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ukpyn-1.0.1.tar.gz.
File metadata
- Download URL: ukpyn-1.0.1.tar.gz
- Upload date:
- Size: 8.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87e57ed0bc3ad9fdb37db1d990629059cd00425bb54dd9f53e7d5d3ac5e51897
|
|
| MD5 |
edb46be3c887b9c54e24b80bcf053385
|
|
| BLAKE2b-256 |
27d6ecc67eb8998ff6a35d3e8b664b8bb1129f9ff5f8478608467cb17929e558
|
Provenance
The following attestation bundles were made for ukpyn-1.0.1.tar.gz:
Publisher:
publish-pypi.yml on UKPN-DSO/ukpyn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ukpyn-1.0.1.tar.gz -
Subject digest:
87e57ed0bc3ad9fdb37db1d990629059cd00425bb54dd9f53e7d5d3ac5e51897 - Sigstore transparency entry: 1188963823
- Sigstore integration time:
-
Permalink:
UKPN-DSO/ukpyn@dfd063a6b9b41ca6067ecdf014b9c636b602103a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/UKPN-DSO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@dfd063a6b9b41ca6067ecdf014b9c636b602103a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ukpyn-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ukpyn-1.0.1-py3-none-any.whl
- Upload date:
- Size: 91.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d3fa568765025499d98648d88ba4aee8a5c60516217d19afa5aa5308d6ed7c3
|
|
| MD5 |
1ae549c65ae4486d82a8679951842cdf
|
|
| BLAKE2b-256 |
f732e7b300c614b76b77b042b115373afcf22b9395a490962abf5c431e6d85d9
|
Provenance
The following attestation bundles were made for ukpyn-1.0.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on UKPN-DSO/ukpyn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ukpyn-1.0.1-py3-none-any.whl -
Subject digest:
1d3fa568765025499d98648d88ba4aee8a5c60516217d19afa5aa5308d6ed7c3 - Sigstore transparency entry: 1188963825
- Sigstore integration time:
-
Permalink:
UKPN-DSO/ukpyn@dfd063a6b9b41ca6067ecdf014b9c636b602103a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/UKPN-DSO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@dfd063a6b9b41ca6067ecdf014b9c636b602103a -
Trigger Event:
workflow_dispatch
-
Statement type: