This package provides a set of tools for interaction with the Energy Transition Model's API. Learn more about the Energy Transition Model here.
The package is designed to be a modular tool that advanced users can incorporate into their scenario workflows. More documentation is available via the docs.
Note: If you are not familiar working with python packages, please refer to the quick start guide first.
Install pyetm from PyPI:
pip install pyetmRequirements: Python 3.12 or later
Check your Python version:
python3 --versionIf you need to install Python:
- Windows: Download from python.org
- macOS: Install via Homebrew:
brew install python@3.12 - Linux: Use your package manager (e.g.,
apt install python3)
We recommend using a virtual environment to keep your project dependencies isolated:
# Create a new virtual environment
python3 -m venv .venv
# Activate it
# On macOS/Linux:
source .venv/bin/activate
# On Windows (PowerShell):
.venv\Scripts\Activate.ps1
# On Windows (Command Prompt):
.venv\Scripts\activate.batMore details on how python virtual environments work can be found here
With your virtual environment activated:
pip install pyetmNote: New versions of pyetm are consistently released. Check here for the latest release
An example of how to install a specific release:
pip install pyetm==2.0.0Run the interactive setup command:
pyetm initThis will:
- Ask which environment you want to use (production, beta, or local)
- Create a
.envconfiguration file - Copy an input template Excel file to
excel/input.xlsx
After initialization, you'll need to manually add your API token to the .env file:
- Open
.envin your text editor - Find the commented
# ETM_API_TOKEN=line - Uncomment it by removing the
# - Paste your full token after the
=sign (get your token here) - Save the file
Note: API tokens are very long (1000+ characters). Make sure you paste the entire token.
Command options:
--environment: Target environment (pro,beta, orlocal)--force: Overwrite existing files without prompting
Example:
pyetm init --environment proThe easiest way to work with scenarios is using Excel files:
# Edit excel/input.xlsx with your scenario data, then run:
pyetm run excel/input.xlsxThis will load your scenarios, update them on ETM, and export results to excel/input_results.xlsx.
Command options:
--output PATHor-o PATH: Custom output file location--log-level: Logging verbosity
Example:
# Custom output location
pyetm run excel/input.xlsx --output results/my_results.xlsx
# Read-only mode (fetch data without updating)
pyetm run excel/input.xlsx --no-updateFor more detailed 'pyetm run' workflow instructions, see the Quick Start Guide in the docs.
The pyetm init command creates a .env file with your settings. You can also configure manually:
Create a .env file in your project directory:
# Your ETM API token (optional for public scenarios)
ETM_API_TOKEN=etm_your_token_here
# Environment (default: pro)
# Options: pro, beta, local, or stable tags like 2025-01
ENVIRONMENT=pro
# Error handling (default: default)
# Options: safe, default, dangerous
PYETM_ERROR_MODE=default
# CSV export settings (optional)
CSV_SEPARATOR=,
DECIMAL_SEPARATOR=.Note on API Token:
- Without a token: You can create and work with public scenarios (read and write operations)
- With a token: Required to access your saved scenarios, list your scenarios, and work with private scenarios
- Get your token here
Environment Options:
pro(default): Production environmentbeta: Staging environmentlocal: Local development environmentYYYY-MM: Stable tagged environment (e.g.,2025-01)
Error Handling Modes:
default(recommended): Errors raise in single operations, warnings collected in bulk operationssafe: All warnings raise exceptions (use in CI/production for maximum safety)dangerous: No warnings raise (use only for exploratory data analysis)
You can override the base URL directly if needed:
BASE_URL=https://engine.energytransitionmodel.com/api/v3For corporate environments or custom certificate setups:
| Option | Default | Description |
|---|---|---|
SSL_VERIFY |
true |
Verify SSL certificates. Set to false only for testing with self-signed certificates. Never disable in production! |
TRUST_ENV |
false |
Enable system proxy environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) |
SSL_CERT_PATH |
(empty) | Path to custom CA certificate bundle for corporate environments |
Example for corporate CA:
SSL_CERT_PATH=/path/to/corporate-ca-bundle.pem
TRUST_ENV=true
HTTP_PROXY=http://proxy.company.com:8080For examples and tutorials, visit our documentation.
The package stores temporary files (cached curves and custom data) in your system's temp directory:
- macOS/Linux:
/tmp/pyetm/ - Windows:
%TEMP%\pyetm\
Interested in contributing to pyetm development? See our Contributing Guide for details on:
- Setting up the development environment with Poetry
- Running tests
- Code style guidelines
- Submitting pull requests
- Documentation: docs.energytransitionmodel.com
- Issues: GitHub Issues
- Repository: github.com/quintel/pyetm