Skip to main content

A unified Python SDK for accessing grid data from all major US Independent System Operators (ISOs)

Project description

Tiny Grid

CI

A Python SDK for accessing electricity grid data from US Independent System Operators (ISOs).

Supported ISOs

  • ERCOT - Electric Reliability Council of Texas

More ISOs (CAISO, PJM, NYISO, ISO-NE, MISO, SPP) planned.

Installation

git clone https://github.com/kvkenyon/tinygrid.git
cd tinygrid
uv sync --dev --all-extras

Quick Start

Using the Unified API

The unified API provides simple, consistent methods for common operations with automatic handling of date parsing, market routing, and historical data access.

from tinygrid import ERCOT
from tinygrid.constants import Market, LocationType

# Authentication is optional for most endpoints
ercot = ERCOT()

# Get today's real-time settlement point prices
prices = ercot.get_spp()

# Get day-ahead prices for load zones
prices = ercot.get_spp(
    start="2024-01-15",
    market=Market.DAY_AHEAD_HOURLY,
    location_type=LocationType.LOAD_ZONE,
)

# Get locational marginal prices
lmp = ercot.get_lmp(start="yesterday")

# Get wind and solar forecasts
wind = ercot.get_wind_forecast(start="today", end="2024-01-20")
solar = ercot.get_solar_forecast(by_region=True)

# Get ancillary services data
as_prices = ercot.get_as_prices(start="2024-01-15")
as_plan = ercot.get_as_plan(start="2024-01-15")

Direct Endpoint Access

For full control, call any of the 100+ ERCOT endpoints directly:

from tinygrid import ERCOT, ERCOTAuth, ERCOTAuthConfig

# Set up authentication for restricted endpoints
auth = ERCOTAuth(ERCOTAuthConfig(
    username="your-email@example.com",
    password="your-password",
    subscription_key="your-subscription-key",
))

ercot = ERCOT(auth=auth)

# Call endpoints directly with specific parameters
load_data = ercot.get_actual_system_load_by_weather_zone(
    operating_day_from="2024-12-20",
    operating_day_to="2024-12-20",
    size=24,
)

forecast = ercot.get_load_forecast_by_weather_zone(
    start_date="2024-12-20",
    end_date="2024-12-27",
    size=100,
)

See examples/ercot_example.py for complete examples.

Unified API Methods

These methods provide a simpler interface with automatic routing, date parsing, and historical data access:

Method Description Markets
get_spp() Settlement Point Prices Real-time 15-min, Day-ahead hourly
get_lmp() Locational Marginal Prices Real-time SCED, Day-ahead hourly
get_as_prices() Ancillary Services MCPC prices Day-ahead
get_as_plan() Ancillary Services plan Day-ahead
get_wind_forecast() Wind power forecast System-wide or by region
get_solar_forecast() Solar power forecast System-wide or by region

Features

  • Date parsing: Use "today", "yesterday", or ISO date strings
  • Automatic historical routing: Seamlessly switches between live and archive APIs based on data age
  • Location filtering: Filter by load zones, trading hubs, or specific settlement points
  • Market selection: Choose between real-time and day-ahead markets
  • Standardized columns: Consistent column names across all endpoints

ERCOT API Credentials

Authentication is required for some endpoints. To get credentials:

  1. Register at ERCOT API Explorer
  2. Subscribe to the API products you need
  3. Use your email, password, and subscription key

Available ERCOT Endpoints

Direct access to 100+ ERCOT endpoints organized by category:

Category Example Methods
Load Data get_actual_system_load_by_weather_zone, get_load_forecast_by_weather_zone, get_load_forecast_by_study_area
Pricing get_dam_hourly_lmp, get_dam_settlement_point_prices, get_lmp_electrical_bus, get_spp_node_zone_hub
Renewables get_wpp_hourly_average_actual_forecast, get_spp_hourly_average_actual_forecast
Ancillary Services get_dam_as_plan, get_total_as_service_offers, get_aggregated_as_offers_*
SCED get_sced_system_lambda, get_sced_gen_res_data, get_sced_dsr_load_data
Shadow Prices get_shadow_prices_bound_transmission_constraint, get_dam_shadow_prices
Outages get_hourly_res_outage_cap, get_aggregated_outage_schedule

All methods accept **kwargs for additional API parameters like size, page, sort, etc.

Constants and Enums

from tinygrid.constants import Market, LocationType, LOAD_ZONES, TRADING_HUBS

# Market types
Market.REAL_TIME_SCED         # Real-time SCED (5-minute)
Market.REAL_TIME_15_MIN       # Real-time 15-minute
Market.DAY_AHEAD_HOURLY       # Day-ahead hourly

# Location types for filtering
LocationType.LOAD_ZONE        # Load zones (LZ_*)
LocationType.TRADING_HUB      # Trading hubs (HB_*)
LocationType.RESOURCE_NODE    # Resource nodes
LocationType.ELECTRICAL_BUS   # Electrical buses

# Pre-defined location lists
LOAD_ZONES = ["LZ_HOUSTON", "LZ_NORTH", "LZ_SOUTH", "LZ_WEST", ...]
TRADING_HUBS = ["HB_HOUSTON", "HB_NORTH", "HB_SOUTH", "HB_WEST", ...]

Error Handling

from tinygrid import ERCOT, GridAPIError, GridTimeoutError, GridAuthenticationError

try:
    data = ercot.get_spp()
except GridAuthenticationError as e:
    print(f"Auth failed: {e.message}")
except GridAPIError as e:
    print(f"API error {e.status_code}: {e.message}")
except GridTimeoutError as e:
    print(f"Timed out after {e.timeout}s")

Project Structure

tinygrid/
├── tinygrid/           # SDK layer
│   ├── ercot.py        # ERCOT client with unified and direct API methods
│   ├── auth/           # Authentication handling
│   ├── constants/      # Market types, location enums, endpoint mappings
│   ├── utils/          # Date parsing, timezone handling, decorators
│   └── errors.py       # Error types
├── pyercot/            # Auto-generated ERCOT API client (from OpenAPI spec)
├── examples/           # Usage examples
└── tests/              # Test suite (258 tests)

Development

This project uses uv for dependency management and just for task automation.

# Install dependencies
just install

# Run tests
just test

# Run tests with coverage
just test-coverage

# Lint
just lint

# Format
just format

# Type check
just type-check

# Run all checks
just check

License

MIT

Author

Kevin Kenyon - kevin@poweredbylight.com

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

tinygrid-0.1.0a0.tar.gz (57.2 kB view details)

Uploaded Source

Built Distribution

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

tinygrid-0.1.0a0-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

Details for the file tinygrid-0.1.0a0.tar.gz.

File metadata

  • Download URL: tinygrid-0.1.0a0.tar.gz
  • Upload date:
  • Size: 57.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tinygrid-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 44b3ea4c1cb364dc91ddb035e464f85f97ce4cd13ead9af786bf0e13e0017738
MD5 80b1fa1610b8a3ecde3e3c5567e7b049
BLAKE2b-256 43884c807bd73f1a152d2f3a651f73bd0bf856128a66bd57e36ea6265ee5bc96

See more details on using hashes here.

File details

Details for the file tinygrid-0.1.0a0-py3-none-any.whl.

File metadata

  • Download URL: tinygrid-0.1.0a0-py3-none-any.whl
  • Upload date:
  • Size: 39.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tinygrid-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 da06ae02abe65e639e45e8b745710477dedf04bfc6ad36a60bf2e3a99ea8de2b
MD5 bfe4e9c6232e13c6ddf527f718274bc9
BLAKE2b-256 24fd515f68261335e36935c32c35abcad0ec31a53945f8c072f33811024a323b

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