Give Claude Code access to Spain's electricity data
Install the python-esios CLI and drop a skill file so Claude Code can search, fetch, and analyze ESIOS indicators from the terminal.
If you work with Spanish electricity market data, you’ve probably spent time writing scripts to pull prices, demand, or generation data from ESIOS. What if your AI coding assistant could do that directly from the terminal?
python-esios ships with a CLI and a Claude Code skill file — a markdown document that teaches Claude how to use the CLI. Drop it into your project, and Claude can search indicators, fetch historical data, run pandas expressions, and export results without you writing a single line of code.
What’s a Claude Code skill?
A skill is a markdown file that Claude Code reads automatically when it’s relevant to your question. It contains instructions, command references, and conventions — everything Claude needs to use a tool correctly.
The python-esios skill teaches Claude:
- The full CLI command reference (
esios indicators search,history,meta,exec) - Common indicator IDs (spot prices, demand, wind, solar)
- Caching behavior (so it doesn’t re-fetch data unnecessarily)
- Geography conventions (geo IDs, name resolution)
- Output formats (table, CSV, JSON, parquet)
Setup
1. Install the library
pip install python-esios 2. Set your API token
Request a free token from REE’s API page, then:
# Option A: environment variable
export ESIOS_API_KEY=your-token-here
# Option B: persistent config
esios config set token your-token-here 3. Add the skill to your project
Copy the skill file into your project’s .claude/skills/ directory:
mkdir -p .claude/skills/esios
curl -o .claude/skills/esios/SKILL.md \
https://raw.githubusercontent.com/datons/python-esios/main/skills/esios/SKILL.md That’s it. Next time you open Claude Code in this project, it will automatically discover the skill.
What Claude can do now
Search indicators
You: “What ESIOS indicators are available for wind generation?”
Claude runs:
esios indicators search "eólica" Out10 lines
┌──────┬──────────────────────────────────────────────────┬─────────────────────┐
│ id │ name │ short_name │
├──────┼──────────────────────────────────────────────────┼─────────────────────┤
│ 12 │ Generación programada PBF Eólica terrestre │ Eólica terrestre │
│ 47 │ Generación programada PVP Eólica terrestre │ Eólica terrestre │
│ 82 │ Generación programada P48 Eólica terrestre │ Eólica terrestre │
│ 83 │ Generación programada P48 Eólica marina │ Eólica marina │
│ 1159 │ Generación medida Eólica terrestre │ Eólica terrestre │
│ ... │ ... │ ... │
└──────┴──────────────────────────────────────────────────┴─────────────────────┘Inspect an indicator
You: “What geographies does indicator 600 cover?”
esios indicators meta 600 Out13 lines
╭──────────── Indicator 600 ────────────╮
│ Name: Precio mercado SPOT │
│ Unit: €/MWh │
│ Granularity: Hora │
│ │
│ Geographies: │
│ 1 Portugal │
│ 2 Francia │
│ 3 España │
│ 8826 Alemania │
│ 8827 Bélgica │
│ 8828 Países Bajos │
╰────────────────────────────────────────╯Fetch historical data
You: “Download Spain’s spot prices for January 2025”
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --geo España Out9 lines
┌─────────────────────────┬─────────┐
│ datetime │ España │
├─────────────────────────┼─────────┤
│ 2025-01-01 00:00:00 │ 108.27 │
│ 2025-01-01 01:00:00 │ 99.00 │
│ 2025-01-01 02:00:00 │ 90.10 │
│ ... │ ... │
└─────────────────────────┴─────────┘
Showing 50 of 744 rowsRun pandas expressions
This is the power move. The exec command fetches data and evaluates any pandas expression on it — no script needed:
You: “What was the average daily spot price in Spain last January?”
esios indicators exec 600 -s 2025-01-01 -e 2025-01-31 --geo España \
-x "df.resample('D').mean().round(2)" Out8 lines
┌─────────────────────────┬─────────┐
│ datetime │ España │
├─────────────────────────┼─────────┤
│ 2025-01-01 │ 100.52 │
│ 2025-01-02 │ 117.40 │
│ 2025-01-03 │ 73.17 │
│ ... │ ... │
└─────────────────────────┴─────────┘You: “Show me descriptive statistics”
esios indicators exec 600 -s 2025-01-01 -e 2025-01-31 --geo España \
-x "df.describe()" You: “Export it to CSV”
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --geo España \
--format csv --output prices.csv Compare multiple indicators
You: “Compare wind and solar P48 generation for last week”
esios indicators exec 82 84 -s 2025-01-20 -e 2025-01-26 \
-x "df.resample('D').sum().round(0)" Real workflow: analyzing price spikes
Here’s what a real conversation looks like. You ask one question, Claude handles the rest:
You: “Find the days in January 2025 where Spain’s spot price exceeded 150 €/MWh for at least one hour. Show me which hours and what the prices were.”
Claude:
- Fetches the data:
esios indicators history 600 -s 2025-01-01 -e 2025-01-31 --geo España \
--format csv --output /tmp/prices.csv - Analyzes it with exec:
esios indicators exec 600 -s 2025-01-01 -e 2025-01-31 --geo España \
-x "df[df['España'] > 150].sort_values('España', ascending=False)" - Summarizes: “There were 12 hours above 150 €/MWh, concentrated on January 8-9 during a cold snap. Peak was 183.42 €/MWh on Jan 8 at 19:00.”
No script. No notebook. Just a question and an answer backed by real data.
Caching makes it fast
The CLI caches data locally as parquet files in ~/.cache/esios/. Once Claude fetches an indicator for a date range, subsequent queries for the same data are instant — no API calls.
Key caching rules:
- Data older than 48h is considered final (never re-fetched)
- Recent data (last 48h) is refreshed on each request (electricity market corrections)
- Each indicator gets its own cache directory
esios cache statusshows cache size and contentsesios cache clearresets everything
Tips for writing good prompts
- Be specific about dates: “January 2025” is better than “last month” — Claude knows the exact
--startand--endflags - Name the indicator if you know it: “indicator 600” saves a search step
- Ask for exports: Claude will use
--format csv --outputautomatically - Chain analysis: “fetch prices, compute daily averages, find the top 5 most expensive days” — Claude will chain
execcalls
Conclusions
With the python-esios skill, Claude Code becomes an electricity market analyst:
esios indicators search— find any indicator in the 2,000+ catalogesios indicators history— fetch data for any date range and geographyesios indicators exec— run pandas expressions without writing scriptsesios indicators meta— inspect units, granularity, and geographies- Automatic caching — fast repeated queries, no unnecessary API calls
The skill file is the bridge: it gives Claude the knowledge to use these commands correctly, with the right flags and conventions.
Resources
- GitHub: datons/python-esios
- PyPI: python-esios
- python-esios library tutorial — Python API with 4 use cases
- ESIOS API documentation
- Claude Code skills documentation