Elexon Python Client
Project description
elexonpy
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 💻 |
Peter Dudfield 👀 |
Matthew Duffin 🤔 |
Jacqueline James 💻 |
Yousef Elsawy 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for elexonpy-1.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6541694962ba56a0d3a490d24af428c38934dd063ce5e2f93fca041ba4f11d00 |
|
MD5 | 9f11793d0ca008c3e3e018adafcc2432 |
|
BLAKE2b-256 | dc29d6d8e68ac853743753a556f1d331b44bf691a5ce8e6d7da2cfaf36c14673 |