Skip to main content

gridstatus logo

Tests PyPI version

GridStatus.io Hosted API

Installation

gridstatusio supports Python 3.10+. Install with uv or pip.

# Standard installation (includes pandas)
uv pip install gridstatusio

# With polars support (for polars DataFrames)
uv pip install gridstatusio[polars]

# With notebook support (for running example notebooks)
uv pip install gridstatusio[notebooks]

# With all optional dependencies
uv pip install gridstatusio[all]

Getting Started

  • Sign up for a Grid Status account and get your API key from the Settings page
  • Set your API key as an environment variable: export GRIDSTATUS_API_KEY=your_api_key or pass to the client with client = GridStatusClient(api_key="<your_api_key>")
  • You're now ready to start querying. List datasets with:
from gridstatusio import GridStatusClient
client = GridStatusClient()

data = client.get_dataset('ercot_fuel_mix', limit=100, start='2025-01-01', end='2025-01-02')
  • To see all available datasets, use client.list_datasets() or check out the complete Grid Status catalog at https://www.gridstatus.io/datasets

  • To get metadata for a single dataset (description, available time range, columns, and more), use client.get_dataset_metadata(dataset_id). It always returns a dictionary, with timestamp fields parsed into timezone-aware datetimes:

metadata = client.get_dataset_metadata("ercot_fuel_mix")

# {
#     "id": "ercot_fuel_mix",
#     "name": "ERCOT Fuel Mix",
#     "earliest_available_time_utc": datetime(2017, 1, 1, 6, 0, tzinfo=timezone.utc),
#     "all_columns": [{"name": "interval_start_utc", ...}, ...],
#     ...
# }

Return Formats

The client supports three return formats for data: pandas DataFrames, polars DataFrames, and Python objects (list of dictionaries). You can specify the format at the client level or per-call.

from gridstatusio import GridStatusClient

# Set default format when creating the client
client = GridStatusClient(return_format="pandas")  # or "polars" or "python"

# Override format for a specific call
data = client.get_dataset('ercot_fuel_mix', limit=100, return_format="python")

Format Options

Format Return Type Description
"pandas" pd.DataFrame Pandas DataFrame with parsed datetime columns
"polars" pl.DataFrame Polars DataFrame with parsed datetime columns
"python" list[dict] List of dictionaries with parsed datetime columns

Default Behavior

If return_format is not specified, the client returns pandas DataFrames by default.

Example: Python Format

from gridstatusio import GridStatusClient

client = GridStatusClient(return_format="python")
data = client.get_dataset('ercot_fuel_mix', limit=5)

# Returns a list of dictionaries
# [
#     {"interval_start_utc": "2025-01-01T00:00:00+00:00", "coal": 1234.5, ...},
#     {"interval_start_utc": "2025-01-01T00:05:00+00:00", "coal": 1235.2, ...},
#     ...
# ]

Example: Polars Format

from gridstatusio import GridStatusClient

client = GridStatusClient(return_format="polars")
df = client.get_dataset('ercot_fuel_mix', limit=100)

# Returns a polars DataFrame
print(type(df))  # <class 'polars.dataframe.frame.DataFrame'>

Using Without Pandas (Advanced)

While pandas is a required dependency, the library uses lazy loading so pandas is only imported when actually needed. This allows advanced users to use the library without pandas in minimal environments:

# Install without dependencies (advanced usage only)
uv pip install gridstatusio --no-deps

# Then manually install only the required non-pandas dependencies
uv pip install requests termcolor tabulate

When using the library without pandas:

from gridstatusio import GridStatusClient

# Must explicitly set return_format="python" to avoid pandas import
client = GridStatusClient(api_key="your_key", return_format="python")
data = client.get_dataset('ercot_fuel_mix', limit=100)

# Returns list of dicts - no pandas required

Note: If you don't specify return_format="python", the client will attempt to use pandas and raise an error if it's not installed.

Checking your API usage

usage = client.get_api_usage()
  • This shows the limits for your API key, the start and end of the current usage period, and the API usage in the current period. Note a limit of -1 means no limit.

Retry Configuration

  • The Grid Status API has rate limits that restrict the number of requests that are allowed each second, minute and hour. If rate limits are hit the client will automatically retry the request after a delay. You can configure the maximum number of retries using the max_retries parameter when initializing the client. If you find yourself hitting rate limits, you may need to add a delay between your requests. The Grid Status Pricing Page contains more details on specific rate limits.
  • The client retries failed requests due to rate limits (429), server errors (5xx), and network issues using exponential backoff. You can customize retry behavior:
client = GridStatusClient(
    max_retries=3,        # Maximum retries (default: 5)
    base_delay=1.0,       # Base delay in seconds (default: 2.0)
    exponential_base=1.5, # Exponential backoff multiplier (default: 2.0)
)

The retry delay follows the formula delay = base_delay * (exponential_base ** retry_count).

Retries are useful when:

  • You're making pagination-heavy requests and risk hitting short-term rate limits
  • A request fails due to a temporary server error
  • A network issue or timeout interrupts the request

To disable retries entirely, set max_retries=0.

Version Check

The client checks for updates to the library when it is imported. It does this by making a call to the library on PyPI. For certain applications, this call can be problematic, and can be disabled by setting the environment variable GSIO_SKIP_VERSION_CHECK to true.

export GSIO_SKIP_VERSION_CHECK=true

Open Source

If you prefer to use an open source library that fetches data directly from the source, you can check out this github repo.

Get Help

We'd love to answer any usage or data access questions! Please let us know by emailing us at contact@gridstatus.io

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gridstatusio-0.16.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

gridstatusio-0.16.0-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file gridstatusio-0.16.0.tar.gz.

File metadata

  • Download URL: gridstatusio-0.16.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gridstatusio-0.16.0.tar.gz
Algorithm Hash digest
SHA256 e943ff05c04c884ca795c84ca33f36c853dd291f68a070735ea11f2b95445f28
MD5 34932c55655fa07c8e30de34b20612b0
BLAKE2b-256 d0e31a82e7885b3d38211731862d1b5a5eb745aa3c170285aa98472c80df0f9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gridstatusio-0.16.0.tar.gz:

Publisher: release.yaml on gridstatus/gridstatusio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gridstatusio-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: gridstatusio-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gridstatusio-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e26dcddba09713f22dc2d0f499d427645f3d5d0188388651c5a20f9c9c6b17a
MD5 d35129f02938864af87acbc3428cfc8d
BLAKE2b-256 5a96a37b508a8955fb82960e6a76de3f5a7292aaf5a8fd080dd1f72d03db950d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gridstatusio-0.16.0-py3-none-any.whl:

Publisher: release.yaml on gridstatus/gridstatusio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.16.0 This release

2 files

0.15.1

2 files

0.15.0

2 files

0.14.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.1

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.9

2 files

0.5.8

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page