Skip to main content

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

Project description

AESO Python API

image image image image

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

Installation

pip install aeso

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.0.tar.gz (5.9 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.0-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: aeso_python_api-0.2.0.tar.gz
  • Upload date:
  • Size: 5.9 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.0.tar.gz
Algorithm Hash digest
SHA256 ebe1666835e1f9dca7e9ee87534374f2a97578e8e7afd6e60e0c305efca19e90
MD5 843687f4076312366eb72cda7fc4d258
BLAKE2b-256 e6d7c51fa22d8110c3acb62a571e5107918deb1a8013531b40500e95b8e75c1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aeso_python_api-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cee766e2af74b1f3623fc0422a0b6dacc0d1406165af0f64d4b519358840caaa
MD5 38a475a2c7b319d13d09510c936ce6cc
BLAKE2b-256 023280ff154e58042d36b9fa8dbd45f8e19d23f8cb32b19e39e8aba475348196

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