Skip to main content
Wattnet Logo

RESTful API

CI Publish Release Please codecov GitHub stars PyPI version PyPI Downloads Python FastAPI OpenAPI 3.1 Docker Hub License Code style: black Imports: isort pre-commit

wattnet-api is the public-facing HTTP interface for the Wattnet platform. It exposes real-time, historical, and forecasted data on the carbon and water footprint of electricity consumption across Europe, fully documented with OpenAPI 3.1 and deployable as a Docker container.

Purpose

Wattnet computes environmental metrics — carbon footprint, water impact, green scores, generation mix — from open electricity market data. wattnet-api makes all of these metrics available over HTTP so that dashboards, research tools, and third-party applications can query them without coupling to Wattnet's internal data pipeline.

The API is organized into five groups of endpoints:

Group Prefix Description
Zones /v1/zones Metadata and boundaries for supported electricity zones
Energy Metrics /v1/generation, /v1/load, /v1/imports, /v1/exports, /v1/mix Electricity generation, consumption, and cross-border flows
Environmental Metrics /v1/footprints, /v1/impacts, /v1/green-score Carbon and water footprint, carbon impact, and green score
Shares Metrics /v1/flow-share, /v1/mix-share, /v1/footprint-share, /v1/impact-share Fractional attribution of flows, mix, footprint, and impact
Factors /v1/factors Emission and consumption factors used in calculations

Architecture

API component diagram

For the full system architecture see the wattnet-architecture repository.

wattnet-api is a FastAPI application served by Uvicorn. It reads energy metrics from wattnet-storage and zone/GeoJSON data from wattnet-data. The API is versioned; all current endpoints live under /v1.

Requirements

  • Python ≥ 3.10
  • Docker (for containerised deployment)
  • A running wattnet-storage backend

Installation

From PyPI

Installs the wattnet-api server and its wattnet-api CLI entrypoint:

pip install wattnet-api

From source

git clone --recurse-submodules https://github.com/wattnet/wattnet-api.git
cd wattnet-api
poetry install

Docker

Pre-built images are published to GHCR and DockerHub for linux/amd64 and linux/arm64. Images are tagged by full version, minor, major, and latest.

# Pull from GHCR
docker pull ghcr.io/wattnet/wattnet-api:latest

# Or from DockerHub
docker pull wattnet/wattnet-api:latest

Run the container:

docker run -p 8000:8000 --env-file config/.env.production ghcr.io/wattnet/wattnet-api:latest

Configuration

The server reads settings from environment variables or a .env file. Copy the example and adjust as needed:

cp config/.env.example config/.env.development
Variable Default Description
WATTNET_ENV development Active environment; selects config/.env.<WATTNET_ENV>
API_HOST localhost Bind address for the Uvicorn server
API_PORT 8000 Listening port
API_DEBUG True Enable debug mode and verbose logging
GEOJSON_PATH (bundled wattnet-data) Directory with GeoJSON zone boundary files
ZONES_FILE_PATH (bundled wattnet-data) Path to the zones YAML file
CROSSBORDERS_FILE_PATH (bundled wattnet-data) Path to the crossborders YAML file
LOG_LEVEL INFO Logging level (DEBUG, INFO, WARNING, …)
LOG_HANDLERS ["console"] Log outputs: "console" and/or "file"
LOG_FILE ./logs/wattnet-api.log Log file path (only used when file handler is active)
STORAGE_DB_URL http://localhost:8123 URL for the wattnet-storage ClickHouse backend
ENTSOE_URL https://web-api.tp.entsoe.eu/api ENTSO-E Transparency Platform API endpoint
ELEXON_URL https://data.elexon.co.uk/bmrs/api/v1 ELEXON Balancing Mechanism Reporting Service endpoint
EPIAS_URL https://seffaflik.epias.com.tr/electricity-service/v1 EPIAS Electricity Market Transparency Platform endpoint

Running the API

With Poetry

wattnet-api

Or directly with Uvicorn:

uvicorn wattnet.api.app:versioned_app --host 0.0.0.0 --port 8000 --reload

With Docker Compose

docker compose up -d

Interactive API Documentation

Once the server is running, explore endpoints, parameters, and responses interactively:

Interface URL
Swagger UI http://localhost:8000/v1/docs
ReDoc http://localhost:8000/v1/redoc
OpenAPI JSON http://localhost:8000/v1/openapi.json

The production instance is available at https://api.wattnet.eu/docs.

The API is versioned. The current version is v1; the base URL is https://api.wattnet.eu/v1/.

Health check

The /v1/status endpoint reports whether the API and its upstream dependencies (wattnet-storage, ENTSO-E, ELEXON, EPIAS) are reachable. Useful for readiness probes in containerised deployments:

curl http://localhost:8000/v1/status

Contributing

Contributions are welcome. See CONTRIBUTING.md for environment setup, code style, and how to run the tests.

License

This repository is licensed under the Apache License 2.0.

See the LICENSE file for more details.

Funding and Acknowledgments

This work is funded by the European Union's Horizon Europe research and innovation programme through the GreenDIGIT project, under grant agreement 101131207.

EU Funded Logo GreenDIGIT Logo
© 2026 Spanish National Research Council (CSIC). All rights reserved.

Release files for wattnet-api 1.0.0

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

Source distribution (sdist)

Source distribution for wattnet-api 1.0.0
File Size Uploaded
wattnet_api-1.0.0.tar.gz 3.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for wattnet-api 1.0.0
File Interpreter ABI Platform
wattnet_api-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 MB

Release files / wattnet_api-1.0.0.tar.gz

Download URL wattnet_api-1.0.0.tar.gz
Size 3.3 MB
Tags Source
SHA-256 checksum
How to use checksums
c234f583f2800632bc23154c482bb09c8a8179182096d93034b47a5fbfa53c52
BLAKE2b-256 checksum
How to use checksums
2e8aaccafe78a888eb46540bde76de87e4065bc04a7404a634564b52695f6f70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.

Transparency log

Release files / wattnet_api-1.0.0-py3-none-any.whl

Download URL wattnet_api-1.0.0-py3-none-any.whl
Size 3.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
baf0b1e23ed55ad45bd150590bce4f096331de2268ed5856ec754a04d9ebd611
BLAKE2b-256 checksum
How to use checksums
cd94f1744a839745efc60c49aa87009d1936e9c466b0b4bb17b37595b002a41b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 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