Skip to content

Elexon BMRS Python Client

A Python client library for accessing the Elexon BMRS (Balancing Mechanism Reporting Service) API. This library provides easy access to UK electricity market data including generation, demand, pricing, and system information.

Python Version License: MIT PyPI version

Features

  • ๐Ÿ”Œ 287 API Endpoints - Complete coverage of all BMRS data
  • ๐Ÿ”‘ API key optional (but recommended for higher rate limits)
  • ๐Ÿ“Š Comprehensive data access - Generation, demand, pricing, balancing, settlement, and more
  • ๐Ÿ”„ Multiple data streams - All BMRS endpoints with streaming support
  • โšก Type-safe responses - Specific response type for each endpoint
  • ๐Ÿ›ก๏ธ Built-in error handling - Detailed exceptions for all error cases
  • ๐Ÿ“ Full type hints - Complete IDE autocomplete support
  • ๐Ÿค– Auto-generated - 287 endpoints + 280 Pydantic models from OpenAPI spec
  • ๐Ÿงช Comprehensive tests - High test coverage for reliability
  • ๐Ÿ“š Complete documentation - Examples and detailed docs for all endpoints

Quick Start

from elexon_bmrs import BMRSClient

# Initialize the client with your API key
client = BMRSClient(api_key="your-api-key-here")

# Get system demand data
demand = client.get_system_demand(
    from_date="2024-01-01",
    to_date="2024-01-02"
)

# Access any of the 287 available endpoints
dynamic_data = client.get_balancing_dynamic(
    bmUnit="2__HFLEX001",
    snapshotAt="2024-01-01T12:00:00Z"
)

print(demand)

Endpoint Categories

The client provides 287 methods organized into these categories:

  • Balancing Mechanism (20+ endpoints) - Dynamic, physical, bid/offer, acceptances
  • Generation (15+ endpoints) - By fuel type, BMU, wind/solar forecasts
  • Demand (10+ endpoints) - National, transmission, peak, rolling demand
  • Pricing & Settlement (25+ endpoints) - System prices, cashflows, volumes
  • Non-BM Services (10+ endpoints) - STOR, DISBSAD, NETBSAD
  • System Data (10+ endpoints) - Frequency, warnings, margin forecasts
  • Datasets (150+ endpoints) - Direct access to 100+ BMRS datasets
  • Reference Data (10+ endpoints) - BMUs, interconnectors, fuel types
  • Streaming (40+ endpoints) - Real-time data streams

See the Complete Endpoint Reference for the full list.

Type-Safe Usage

from elexon_bmrs import BMRSClient, SystemDemandResponse
from elexon_bmrs.generated_models import DemandOutturnNational

client = BMRSClient(api_key="your-api-key")

# Each method returns its own specific response type
response: SystemDemandResponse = client.get_system_demand(
    from_date="2024-01-01",
    to_date="2024-01-02"
)

# Full type safety and IDE autocomplete
for item in response.data:
    demand = DemandOutturnNational(**item)
    print(f"Date: {demand.settlement_date}, Demand: {demand.demand} MW")

Installation

Install from PyPI:

pip install elexon-bmrs

For development installation:

git clone https://github.com/benjaminwatts/balancing.git
cd balancing
pip install -e ".[dev]"

Next Steps

Resources

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This is an unofficial client library and is not affiliated with or endorsed by Elexon Limited. Use of the BMRS API is subject to Elexon's terms and conditions.