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.
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:
For development installation:
Next Steps
- Installation Guide - Detailed installation instructions
- Quick Start Guide - Get up and running quickly
- API Reference - Complete API documentation
- Examples - Code examples and patterns
Resources
- Elexon BMRS Website
- Elexon Portal - Register for API key
- API Documentation
- GitHub Repository
- PyPI Package
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.