https://github.com/openclimatefix/elexonpy
Python package wrapper around Elexon api
https://github.com/openclimatefix/elexonpy
Last synced: about 1 year ago
JSON representation
Python package wrapper around Elexon api
- Host: GitHub
- URL: https://github.com/openclimatefix/elexonpy
- Owner: openclimatefix
- License: mit
- Created: 2024-05-16T15:54:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-26T20:43:03.000Z (over 1 year ago)
- Last Synced: 2025-03-24T10:07:00.382Z (about 1 year ago)
- Language: Python
- Size: 1010 KB
- Stars: 18
- Watchers: 3
- Forks: 7
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# elexonpy
[](#contributors-)
[](https://github.com/openclimatefix/ocf-template/tags)
[](https://pypi.org/project/elexonpy)
[](https://github.com/openclimatefix#how-easy-is-it-to-get-involved)
**elexonpy** is a Python package that provides a convenient interface to the [ELEXON API](https://developer.data.elexon.co.uk/).
This package is generated using Swagger Codegen, ensuring compatibility and ease of use with the ELEXON API services.
## Installation
You can install the `elexonpy` package via pip from PyPI.
```shell
pip install elexonpy
```
## Examples usage
There are some examples in the `examples` directory that demonstrate how to use the package to retrieve data from the Elexon API.
### Example 1: Demand
This example demonstrates how to use methods from the `DemandApi` to retrieve various types of
demand data from the Elexon API and format it into a DataFrame.
```python
# This script demonstrates the use of methods from the DemandApi
# to retrieve various types of demand data from the Elexon API.
from datetime import datetime
import pandas as pd
from elexonpy.api_client import ApiClient
from elexonpy.api.demand_api import DemandApi
# Initialize API client
api_client = ApiClient()
demand_api = DemandApi(api_client)
# Define date range for Actual Total Load Data
from_date = datetime(2024, 7, 1)
to_date = datetime(2024, 7, 2)
# Fetch Actual Total Load Data from API
df = demand_api.demand_actual_total_get(
_from=from_date,
to=to_date,
settlement_period_from=1,
settlement_period_to=48,
format='dataframe'
)
# Print Actual Total Load Data DataFrame
print("\n--- Actual Total Load Data ---")
print(df.head())
```
### Example 2: SIP price
This example demonstrates how to use methods from the `IndicativeImbalanceSettlementApi`
to retrieve settlement system prices data from the Elexon API and format it into a DataFrame.
Example 2
```python
# This script demonstrates the use of methods from the IndicativeImbalanceSettlementApi
# to retrieve settlement system prices data from the Elexon API.
from datetime import datetime
import pandas as pd
from elexonpy.api_client import ApiClient
from elexonpy.api.indicative_imbalance_settlement_api import IndicativeImbalanceSettlementApi
## Initialize API client
api_client = ApiClient()
imbalance_settlement_api = IndicativeImbalanceSettlementApi(api_client)
# Define settlement date
settlement_date = '2024-07-02'
# Fetch system prices data from API
df = imbalance_settlement_api.balancing_settlement_system_prices_settlement_date_get(
settlement_date=settlement_date,
format='dataframe'
)
# Print DataFrame
print("\n--- Settlement System Prices Data ---")
print(df.head())
```
### Example 3 : DA Solar and Wind Forecast
This example demonstrates how to use methods from the `GenerationForecastApi` to retrieve
day-ahead forecast data for wind and solar generation from the Elexon API and format it into a DataFrame.
Example 3
```python
# This script demonstrates the use of methods from the GenerationForecastApi
# to retrieve day-ahead forecast data for wind and solar generation from the Elexon API.
from datetime import datetime
import pandas as pd
from elexonpy.api_client import ApiClient
from elexonpy.api.generation_forecast_api import GenerationForecastApi
# Initialize API client
api_client = ApiClient()
forecast_api = GenerationForecastApi(api_client)
# Define date range for fetching day-ahead wind and solar forecast data
from_date = datetime(2024, 7, 1)
to_date = datetime(2024, 7, 7) # Note: Maximum data output range is 7 days
# Fetch day-ahead forecast data for wind and solar from API
df = forecast_api.forecast_generation_wind_and_solar_day_ahead_get(
_from=from_date,
to=to_date,
process_type='day ahead',
format='dataframe'
)
# Print DataFrame
print("\n--- Day-Ahead Wind and Solar Forecast Data ---")
print(df.head())
```
## Documentation
### API Endpoints
Documentation for the API Endpoints can be found [here](./docs/DocApiEndpointsList.md)
### Models
Documentation for the Models can be found [here](./docs/DocModelsList.md)
### Authorization
All endpoints do not require authorization.
## FAQ
### How do I get an API key?
You dont need one. The Elexon API does not require an API key for access.
### How do I get a year worth of data?
You currently have to write a loop yourself. We hope to incorporate this into the package in the future.
## Development
To install the package directly from the GitHub repository, use the following command:
```shell
pip install git+https://github.com/openclimatefix/Elexonpy.git
```
### Tests
To run the tests, make sure you have `pytest` installed
```bash
pip install pytest
```
and then you can run
```bash
pytest
```
## Contributing and community
[](https://github.com/openclimatefix/elexonpy/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
- PR's are welcome! See the [Organisation Profile](https://github.com/openclimatefix) for details on contributing
- Find out about our other projects in the [OCF Meta Repo](https://github.com/openclimatefix/ocf-meta-repo)
- Check out the [OCF blog](https://openclimatefix.org/blog) for updates
- Follow OCF on [LinkedIn](https://uk.linkedin.com/company/open-climate-fix)
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Richa
💻

Peter Dudfield
👀

Matthew Duffin
🤔

Jacqueline James
💻

Yousef Elsawy
📖

Utkarsh Verma
🚧

Anas Khan
🚧
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
*Part of the [Open Climate Fix](https://github.com/orgs/openclimatefix/people) community.*
[](https://openclimatefix.org)