Skip to main content

Elexon Python Client

Project description

elexonpy

All Contributors

elexonpy is a Python package that provides a convenient interface to the ELEXON API.

This package is generated using Swagger Codegen, ensuring compatibility and ease of use with the ELEXON API services. The package is available on PyPI and can be easily installed via pip.

Requirements.

Python 2.7 and 3.4+

Installation

You can install the elexonpy package via pip from PyPI or directly from GitHub.

Install from PyPI

pip install elexonpy

Install from GitHub

To install the package directly from the GitHub repository, use the following command:

 pip install git+https://github.com/openclimatefix/Elexonpy.git

Examples from examples folder

Example 1 :

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 using pandas.

# 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
response = demand_api.demand_actual_total_get(
    _from=from_date,
    to=to_date,
    settlement_period_from=1,
    settlement_period_to=48,
    format='json'
)

# Convert response to DataFrame
df = pd.DataFrame([data.to_dict() for data in response.data])

# Print Actual Total Load Data DataFrame
print("\n--- Actual Total Load Data ---")
print(df.head())

Example 2:

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 using pandas.

# 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
response = imbalance_settlement_api.balancing_settlement_system_prices_settlement_date_get(
    settlement_date=settlement_date,
    format='json'
)

# Convert response data to DataFrame
df = pd.DataFrame([data.to_dict() for data in response.data])

# Print DataFrame
print("\n--- Settlement System Prices Data ---")
print(df.head())

Example 3 :

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 using pandas.

# 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
response = forecast_api.forecast_generation_wind_and_solar_day_ahead_get(
    _from=from_date,
    to=to_date,
    process_type='day ahead',
    format='json'
)

df = pd.DataFrame([data.to_dict() for data in response.data])

# Print DataFrame
print("\n--- Day-Ahead Wind and Solar Forecast Data ---")
print(df.head())

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function
import time
import elexonpy
from elexonpy.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = elexonpy.AvailabilityApi(elexonpy.ApiClient(configuration))
format = 'format_example' # str | Response data format. Use json/xml to include metadata. (optional)

try:
    # Fourteen-day generation forecast
    api_instance.generation_availability_summary14_d_get(format=format)
except ApiException as e:
    print("Exception when calling AvailabilityApi->generation_availability_summary14_d_get: %s\n" % e)

# create an instance of the API class
api_instance = elexonpy.AvailabilityApi(elexonpy.ApiClient(configuration))
format = 'format_example' # str | Response data format. Use json/xml to include metadata. (optional)

try:
    # Three-year generation forecast
    api_instance.generation_availability_summary3_yw_get(format=format)
except ApiException as e:
    print("Exception when calling AvailabilityApi->generation_availability_summary3_yw_get: %s\n" % e)

Documentation for API Endpoints

Documentation for the API Endpoints can be found here

Documentation For Models

Documentation for the Models can be found here

Documentation For Authorization

All endpoints do not require authorization.

Author

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Richa
Richa

💻
Peter Dudfield
Peter Dudfield

👀
Matthew Duffin
Matthew Duffin

🤔
Jacqueline James
Jacqueline James

💻
Yousef Elsawy
Yousef Elsawy

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

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

elexonpy-1.0.10.tar.gz (229.8 kB view hashes)

Uploaded Source

Built Distribution

elexonpy-1.0.10-py3-none-any.whl (617.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page