Skip to main content

Python Client for Elia Open Data

Project description

PyPI Build Status Latest dev release

Elia OpenData Python Client

A Python client for accessing the Elia Open Data Portal API. This client provides a simple interface to access Elia's energy data with support for easy data conversion to popular data science formats.

Installation

For stable releases, you can install the package from PyPI:

pip install elia-opendata

Nightly/Pre-release Version

You can install the latest pre-release (nightly) build directly from GitHub Releases:

  1. Go to the Releases page and find the most recent pre-release.
  2. Copy the link to the .whl file attached to that release.
  3. Install with:
pip install https://github.com/WattsToAnalyze/elia-opendata/releases/download/<TAG>/<WHEEL_FILENAME>

Or, if you have set up a "latest-nightly" tag as discussed, you can use:

pip install https://github.com/WattsToAnalyze/elia-opendata/releases/download/latest-nightly/elia_opendata-latest.whl

Development Version (from source)

You can also install the development version directly from the main branch:

pip install git+https://github.com/WattsToAnalyze/elia-opendata.git@main

Usage

Basic Usage

from elia_opendata import EliaClient, Dataset, DatasetCategory

# Initialize client
client = EliaClient()

# List all available datasets
catalog = client.get_catalog()
for entry in catalog:
    print(f"Dataset: {entry.title} (ID: {entry.id})")

# Get dataset metadata using enum
solar_metadata = client.get_dataset(Dataset.PV_PRODUCTION)
# print(f"Solar data fields: {solar_metadata.fields}")

# Get records from a dataset
solar_data = client.get_records(Dataset.PV_PRODUCTION, limit=100)
print(solar_data)
print("First 5 solar records:")
for record in getattr(solar_data, 'records', [])[:5]:
    print(record)

# Convert to different formats
df = solar_data.to_pandas()  # Convert to pandas DataFrame
np_array = solar_data.to_numpy()  # Convert to numpy array
pl_df = solar_data.to_polars()  # Convert to polars DataFrame
arrow_table = solar_data.to_arrow()  # Convert to Arrow table

Exploring Available Datasets

from elia_opendata import DatasetCategory

# Get all generation-related datasets
generation_datasets = Dataset.by_category(DatasetCategory.GENERATION)
for dataset in generation_datasets:
    print(f"Generation dataset: {dataset.value}")

# Available categories
print("Available categories:")
for category in DatasetCategory:
    print(f"- {category.value}")

Handling Large Datasets

# Iterate through large datasets in batches
for batch in client.iter_records(Dataset.ACTUAL_TOTAL_LOAD, batch_size=1000):
    df = batch.to_pandas()
    # Process your batch

Dataset Categories

The client provides enums for easy access to different types of data:

  • Consumption Data: Total load, day-ahead and week-ahead forecasts
  • Generation Data: Solar and wind generation, offshore/onshore forecasts
  • Transmission Data: Cross-border flows, scheduled exchanges
  • Balancing Data: Imbalance prices, system imbalance
  • Congestion Management: Redispatch measures, costs
  • Capacity Data: Transmission and installed capacity
  • Bidding Zone Data: Prices and cross-border capacity

API Endpoints

The client maps directly to Elia's API endpoints:

  • get_catalog(): List all available datasets (GET /api/v2/catalog/datasets)
  • get_dataset(): Get dataset metadata (GET /api/v2/catalog/datasets/{dataset_id})
  • get_records(): Get dataset records (GET /api/v2/catalog/datasets/{dataset_id}/records)
  • search_catalog(): Search datasets (GET /api/v2/catalog/datasets/search)

Dependencies

Core dependencies:

  • requests

Optional dependencies for data conversion:

  • pandas
  • numpy
  • polars
  • pyarrow

Advanced Data Processing

The library includes an EliaDataProcessor that makes it easy to work with large datasets and perform common data manipulation tasks:

from elia_opendata import EliaClient, EliaDataProcessor, Dataset
from datetime import datetime, timedelta

# Initialize the data processor
processor = EliaDataProcessor()

# Fetch a complete dataset (automatically handles pagination)
solar_data = processor.fetch_complete_dataset(
    dataset=Dataset.PV_PRODUCTION,
    batch_size=100  # Number of records per API request (max 100)
)
print(f"Retrieved {solar_data.total_count} solar production records")

# Fetch data for a specific date range
end_date = datetime.utcnow()
start_date = end_date - timedelta(days=7)

wind_data = processor.fetch_date_range(
    dataset=Dataset.WIND_PRODUCTION,
    start_date=start_date,
    end_date=end_date
)

# Aggregate data by a field
# For example, aggregate solar production by region
region_sum = processor.aggregate_by_field(
    solar_data,
    "region",
    {"measured": "sum", "datetime": "max"}
)
print(region_sum.to_pandas())

# Converting to different DataFrame formats
pandas_df = processor.to_dataframe(solar_data, output_format="pandas")
polars_df = processor.to_dataframe(solar_data, output_format="polars")
numpy_array = processor.to_dataframe(solar_data, output_format="numpy")

The EliaDataProcessor makes working with Elia OpenData more efficient by handling:

  • Automatic pagination for large datasets
  • Date filtering with optimized API calls
  • Simplified data aggregation
  • Format conversion between pandas, polars, and numpy

License

MIT License

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

elia_opendata-0.2.1.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elia_opendata-0.2.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file elia_opendata-0.2.1.tar.gz.

File metadata

  • Download URL: elia_opendata-0.2.1.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for elia_opendata-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c89cdc51683c8764deb12c3f9d28208b1313b090014a377f4440769b6940bd20
MD5 2854aae11a091f04722b1b4107729240
BLAKE2b-256 d97acc7fdecfb404d0e635377a9a6c6edba6cc3baa868682c33bee3735c02b98

See more details on using hashes here.

File details

Details for the file elia_opendata-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: elia_opendata-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for elia_opendata-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 356f0550dbf280be837f670b241193852301ac01ffc573717a05abafb4e670bd
MD5 322c627929e08ce19f9ff1736fb1c42a
BLAKE2b-256 0f8696a5d059653d3f964b8da0b875b2aaf3b6b8663e2f5cda91183664af0517

See more details on using hashes here.

Supported by

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