Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Electricity Maps Python SDK

Real-time and historical electricity data to help developers build a more sustainable future. If you want to join us in making electricity consumption more transparent and sustainable Check out our careers page.

PyPi page link -- version python Twitter Follow


Official Electricity Maps SDK for Python

Welcome to the official Python SDK for Electricity Maps.

⚠️ Beta Notice: This SDK is currently in beta. While functional, the API may change before the stable release. We welcome feedback and contributions!

📦 Getting Started

Prerequisites

You need an Electricity Maps API key. Sign up for free to get started.

Installation

Getting the Electricity Maps SDK into your project is straightforward. Just run this command in your terminal:

pip install electricitymaps

Basic Configuration

Here's a quick configuration example to get started:

import os
from electricitymaps import create_client

# Create a client with your API key
client = create_client(api_key=os.environ["ELECTRICITY_MAPS_API_KEY"])

⚡ Supported Signals

The SDK provides access to the following electricity data signals:

Signal Latest Forecast History Description
Carbon Intensity ✅ ✅ ✅ Real-time and forecasted carbon intensity (gCO2eq/kWh)
Power Breakdown ✅ ❌ ✅ Electricity generation by source (coal, gas, nuclear, solar, wind, etc.)
Renewable Energy ✅ ❌ ❌ Percentage of renewable energy in the electricity mix
Carbon-Free Energy ✅ ❌ ❌ Percentage of carbon-free energy sources
Total Load ✅ ❌ ✅ Total electricity demand/consumption
Net Load ✅ ❌ ✅ Load minus renewable generation
Day-Ahead Prices ✅ ❌ ✅ Next-day electricity market prices

Note: All signals support querying by both zone keys (e.g., "DK-DK1") and geographic coordinates (latitude/longitude).

Coverage: This table shows the current SDK coverage. The full Electricity Maps API offers additional endpoints and functionality. For complete API documentation and all available endpoints, visit our Developer Hub.

🚀 Quick Usage Examples

Carbon Intensity

# Get latest carbon intensity for Denmark West
result = client.carbon_intensity.latest(zone_key="DK-DK1")
print(f"Carbon intensity: {result.carbon_intensity} gCO2eq/kWh")

# Get 24-hour carbon intensity forecast
forecast = client.carbon_intensity.forecast(zone_key="DK-DK1", horizon_hours=24)
print(f"Forecast: {forecast}")

# Get historical carbon intensity data
history = client.carbon_intensity.history(zone_key="DK-DK1")
print(f"Historical data: {history}")

Power Breakdown

# Get current power generation breakdown
breakdown = client.power_breakdown.latest(zone_key="DK-DK1")
print(f"Power sources: {breakdown}")

# Get historical power breakdown
history = client.power_breakdown.history(zone_key="DK-DK1")
print(f"Historical breakdown: {history}")

Renewable and Carbon-Free Energy

# Get current renewable energy share
renewable = client.renewable_energy.latest(zone_key="DK-DK1")
print(f"Renewable energy share: {renewable}")

# Get carbon-free energy share
carbon_free = client.carbon_free_energy.latest(zone_key="DK-DK1")
print(f"Carbon-free energy share: {carbon_free}")

Load and Pricing Data

# Get total electricity load
total_load = client.total_load.latest(zone_key="DK-DK1")
print(f"Total load: {total_load}")

# Get net load (load minus renewables)
net_load = client.net_load.latest(zone_key="DK-DK1")
print(f"Net load: {net_load}")

# Get day-ahead electricity prices
prices = client.price_day_ahead.latest(zone_key="DK-DK1")
print(f"Day-ahead prices: {prices}")

Using Coordinates

Most endpoints support both zone keys and geographic coordinates:

# Get data by coordinates (Copenhagen)
result = client.carbon_intensity.latest(lat=55.6761, lon=12.5683)
print(f"Carbon intensity: {result.carbon_intensity} gCO2eq/kWh")

# Forecast by coordinates
forecast = client.carbon_intensity.forecast(
    lat=55.6761, 
    lon=12.5683, 
    horizon_hours=48
)
print(f"48-hour forecast: {forecast}")

📚 Documentation

For more details on API endpoints, parameters, and response formats, check out our full documentation at https://portal.electricitymaps.com/developer-hub/api/getting-started.

🔑 Authentication

The SDK uses API key authentication. You can obtain your API key from the Electricity Maps dashboard.

Set your API key as an environment variable:

export ELECTRICITY_MAPS_API_KEY="your-api-key-here"

🛟 Need Help?

If you encounter issues or need help setting up the SDK, please:

🔗 Resources

📃 License

This SDK is open-source and available under the MIT license.

🌱 Contributing

We welcome contributions! This SDK is part of our mission to make electricity consumption more transparent and sustainable. Every contribution helps us build a better future.

Metadata

Release files for electricitymaps 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for electricitymaps 0.0.1
File Size Uploaded
electricitymaps-0.0.1.tar.gz 66.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for electricitymaps 0.0.1
File Interpreter ABI Platform
electricitymaps-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 198.9 kB

Release files / electricitymaps-0.0.1.tar.gz

Download URL electricitymaps-0.0.1.tar.gz
Size 66.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c396871c922049c87e5b0923bdb7b7d95141a9604507b7b96ea0274891040c42
BLAKE2b-256 checksum
How to use checksums
fa26d4ef4ac4d1d666584dbe00b661f8dadec13e941265321ce2e3cdc7a0d4ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.13

Release files / electricitymaps-0.0.1-py3-none-any.whl

Download URL electricitymaps-0.0.1-py3-none-any.whl
Size 132.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67664642b6059c4cbcaf22770d6d87df44679e2fffca68fc4222f2ec097cba29
BLAKE2b-256 checksum
How to use checksums
0ab2a6299ec64d0d61a57136c9812c28c8013815825a6ad78834a7ad9b78e5ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.13

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release 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