Skip to main content

A Python wrapper for the Alberta Electric System Operator (AESO) API

Project description

AESO Python API

PyPI version Downloads Build Status License: MIT

A Python wrapper for the Alberta Electric System Operator (AESO) API. Easily access pool price reports and electricity market data.

Installation

pip install aeso-python-api

Getting Started

1. Get Your API Key

Register for a free API key at the AESO API Portal.

2. Basic Usage

import os
from aeso import AESOAPI

# Initialize with your API key from environment variable
api_key = os.environ.get('AESO_API_KEY')

# Or directly (not recommended for production)
# api_key = "your-api-key-here"

aeso = AESOAPI(api_key)

# Fetch pool price data
prices = aeso.get_pool_price_report(
    start_date="2023-06-12",
    end_date="2023-06-13"
)

print(prices)

API Reference

Pool Price Report

Fetch electricity pool price data for a specified date range.

Parameters:

  • start_date (str, required): Start date in format YYYY-MM-DD
  • end_date (str, optional): End date in format YYYY-MM-DD

If end_date is omitted, data will include pool price values for all completed settlement hours of the day specified by start_date.

Returns:

A list of PoolPrice objects with the following attributes:

@dataclass
class PoolPrice:
    begin_datetime_utc: datetime  # Start time in UTC
    begin_datetime_mpt: datetime  # Start time in Mountain Time
    pool_price: float            # Pool price in $/MWh
    forecast_pool_price: float   # Forecasted pool price
    rolling_30day_avg: float     # 30-day rolling average

Example:

from aeso import AESOAPI
import os

aeso = AESOAPI(os.environ.get('AESO_API_KEY'))

# Get prices for a date range
prices = aeso.get_pool_price_report(
    start_date="2023-06-12",
    end_date="2023-06-13"
)

# Access the data
for price in prices:
    print(f"{price.begin_datetime_mpt}: ${price.pool_price}/MWh")

Working with Data

Convert to Pandas DataFrame

import pandas as pd
from aeso import AESOAPI
import os

aeso = AESOAPI(os.environ.get('AESO_API_KEY'))

prices = aeso.get_pool_price_report(
    start_date="2023-06-12",
    end_date="2023-06-13"
)

# Convert to DataFrame
df = pd.DataFrame(prices)
print(df.head())

Convert to Spark DataFrame

import pandas as pd
from aeso import AESOAPI
import os

aeso = AESOAPI(os.environ.get('AESO_API_KEY'))

prices = aeso.get_pool_price_report(
    start_date="2023-06-12",
    end_date="2023-06-13"
)

# Convert to pandas first
pdf = pd.DataFrame(prices)

# Then to Spark
spark_df = spark.createDataFrame(pdf)

Testing Your Setup

You can test the API by using the example file:

# Set your API key
export AESO_API_KEY='your-api-key-here'

# Copy and run the example
cp example_template.py example.py
# Edit example.py with your API key, then:
python example.py

Security Note

⚠️ Keep your API key secure

  • Use environment variables instead of hardcoding your API key
  • Never commit your API key to version control
  • Files like example.py, test_new_api.py, and config.py are gitignored for your security

Requirements

  • Python 3.6+
  • requests >= 2.26.0

Resources

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

aeso_python_api-0.2.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

aeso_python_api-0.2.1-py2.py3-none-any.whl (8.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: aeso_python_api-0.2.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for aeso_python_api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0420647abeb46dda8076c95038ca09dd3264618568ff1e91bd2f9bec8be5ae7a
MD5 33c015b7bb74afd4184a1e4def37935d
BLAKE2b-256 e8f8695ef9e93943695afcaf3808864948b08f8436f34e0d11a2c6732dfd6383

See more details on using hashes here.

File details

Details for the file aeso_python_api-0.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aeso_python_api-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f82024822531339c8ff04bf4497c114b6ae4d427832759f13cb5e5b7a3ebd09d
MD5 349c8d8dd08031fd9b93e37536319fdf
BLAKE2b-256 8060bc0b79d354f4cf82a41c54a788b72b7dfb01361c1543d07946b130e5e90a

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