Home

Awesome

Elexon Data Portal

DOI Binder PyPI version

The ElexonDataPortal library is a Python Client for retrieving data from the Elexon/BMRS API. The library significantly reduces the complexity of interfacing with the Elexon/BMRS API through the standardisation of parameter names and orchestration of multiple queries when making requests over a date range. To use the ElexonDataPortal you will have to register for an Elexon API key which can be done here.

<br> <br>

Installation

The library can be easily installed from PyPi, this can be done using:

pip install ElexonDataPortal
<br> <br>

Getting Started

We'll begin by initialising the API Client. The key parameter to pass here is the api_key, alternatively this can be set by specifying the environment variable BMRS_API_KEY which will then be loaded automatically.

from ElexonDataPortal import api

client = api.Client('your_api_key_here')
<br>

Now that the client has been initialised we can make a request!

One of the key abstractions within the ElexonDataPortal library is the handling of multiple requests over a date range specified through the start_date and end_date parameters. Each response will be automatically cleaned and parsed, then concatenated into a single Pandas DataFrame. If a settlement period and date column can be identified in the returned data then a new column will be added with the local datetime for each data-point. N.b. that if passed as a string the start and end datetimes will be assumed to be in the local timezone for the UK

start_date = '2020-01-01'
end_date = '2020-01-01 1:30'

df_B1610 = client.get_B1610(start_date, end_date)

df_B1610.head(3)
documentTypebusinessTypeprocessTypetimeSeriesIDcurveTypesettlementDatepowerSystemResourceTyperegisteredResourceEICCodemarketGenerationUnitEICCodemarketGenerationBMUIdmarketGenerationNGCBMUIdbMUnitIDnGCBMUnitIDactiveFlagdocumentIDdocumentRevNumresolutionstartendsettlementPeriodquantitylocal_datetime
0Actual generationProductionRealisedELX-EMFIP-AGOG-TS-212Sequential fixed size block2020-01-01Generation48W000CAS-BEU01F48W000CAS-BEU01FM_CAS-BEU01CAS-BEU01M_CAS-BEU01CAS-BEU01YELX-EMFIP-AGOG-224953861PT30M2020-01-012020-01-01118.5082020-01-01 00:00:00+00:00
1Actual generationProductionRealisedELX-EMFIP-AGOG-TS-355Sequential fixed size block2020-01-01Generation48W00000STLGW-3A48W00000STLGW-3AT_STLGW-3STLGW-3T_STLGW-3STLGW-3YELX-EMFIP-AGOG-224953861PT30M2020-01-012020-01-01128.2182020-01-01 00:00:00+00:00
2Actual generationProductionRealisedELX-EMFIP-AGOG-TS-278Sequential fixed size block2020-01-01Generation48W00000GNFSW-1H48W00000GNFSW-1HT_GNFSW-1GNFSW-1T_GNFSW-1GNFSW-1YELX-EMFIP-AGOG-224953861PT30M2020-01-012020-01-01129.442020-01-01 00:00:00+00:00
<br>

If you've previously written your own code for extracting data from the Elexon/BMRS API then you may be wondering where some of the normal parameters you pass have gone. The reduction in the parameters passed are due to 4 core drivers:

The full list of data streams that are able to be requested can be found here. If you wish to make requests using the raw methods these are available through the ElexonDataportal.dev.raw module.

Further information can be found in the Quick Start guide.

<br> <br>

What's Changed in v2

The latest release of the library includes a full rewrite of the code-base. We have endeavoured to make the new API as intuitive as possible but that has required breaking changes from v1, if you wish to continue using the historic library use pip install ElexonDataPortal==1.0.4. N.b v1 will not be maintained going forward, you are advised to change over to v2.0.0+.

The key feature changes are:

<br> <br>

Programmatic Library Generation

One of the core features within the ElexonDataPortal library is that it is self-generating, by which we mean it can rebuild itself (including any new API request methods) from scratch using only the endpoints.csv spreadsheet. As well as generating the Python Client library a BMRS_API.yaml file is created, this provides an OpenAPI specification representation of the Elexon/BMRS API. In turn this allows us to automatically generate documentation, as well as run tests on the API itself to ensure that everything is working as expected - during this process we identified and corrected several small errors in the API documentation provided by Elexon.

To rebuild the library simply run the following in the root directory:

python -m ElexonDataPortal.rebuild
<br>

N.b. If you wish to develop the library further or use any of the programmatic library generation functionality then please install the development version of the library using:

pip install ElexonDataPortal[dev]

If you are not installing into a fresh environment it is recommended you install pyyaml and geopandas using conda to avoid any dependency conflicts. In future we are looking to release ElexonDataPortal as a conda package to avoid these issues.

<br> <br>

Data Stream Descriptions

The following table describes the data streams that are currently retreivable through the API. The client method to retrieve data from a given stream follows the naming convention get_{stream-name}.

StreamDescription
B0610Actual Total Load per Bidding Zone
B0620Day-Ahead Total Load Forecast per Bidding Zone
B0630Week-Ahead Total Load Forecast per Bidding Zone
B0640Month-Ahead Total Load Forecast Per Bidding Zone
B0650Year Ahead Total Load Forecast per Bidding Zone
B0710Planned Unavailability of Consumption Units
B0720Changes In Actual Availability Of Consumption Units
B0810Year Ahead Forecast Margin
B0910Expansion and Dismantling Projects
B1010Planned Unavailability In The Transmission Grid
B1020Changes In Actual Availability In The Transmission Grid
B1030Changes In Actual Availability of Offshore Grid Infrastructure
B1320Congestion Management Measures Countertrading
B1330Congestion Management Measures Costs of Congestion Management
B1410Installed Generation Capacity Aggregated
B1420Installed Generation Capacity per Unit
B1430Day-Ahead Aggregated Generation
B1440Generation forecasts for Wind and Solar
B1510Planned Unavailability of Generation Units
B1520Changes In Actual Availability of Generation Units
B1530Planned Unavailability of Production Units
B1540Changes In Actual Availability of Production Units
B1610Actual Generation Output per Generation Unit
B1620Actual Aggregated Generation per Type
B1630Actual Or Estimated Wind and Solar Power Generation
B1720Amount Of Balancing Reserves Under Contract Service
B1730Prices Of Procured Balancing Reserves Service
B1740Accepted Aggregated Offers
B1750Activated Balancing Energy
B1760Prices Of Activated Balancing Energy
B1770Imbalance Prices
B1780Aggregated Imbalance Volumes
B1790Financial Expenses and Income For Balancing
B1810Cross-Border Balancing Volumes of Exchanged Bids and Offers
B1820Cross-Border Balancing Prices
B1830Cross-border Balancing Energy Activated
BODBid Offer Level Data
CDNCredit Default Notice Data
DERSYSDATADerived System Data
DETSYSPRICESDetailed System Prices
DEVINDODDaily Energy Volume Data
DISBSADBalancing Services Adjustment Action Data
FORDAYDEMForecast Day and Day Ahead Demand Data
FREQRolling System Frequency
FUELHHHalf Hourly Outturn Generation by Fuel Type
MELIMBALNGCForecast Day and Day Ahead Margin and Imbalance Data
MIDMarket Index Data
MessageDetailRetrievalREMIT Flow - Message List Retrieval
MessageListRetrievalREMIT Flow - Message List Retrieval
NETBSADBalancing Service Adjustment Data
NONBMNon BM STOR Instructed Volume Data
PHYBMDATAPhysical Data
SYSDEMSystem Demand
SYSWARNSystem Warnings
TEMPTemperature Data
WINDFORFUELHHWind Generation Forecast and Out-turn Data