Skip to content

dockerized-nl/stroomprijs-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stroomprijs API

A FastAPI application for electricity pricing in the Netherlands, fetching data from EnergyZero API.

Features

  • View electricity prices for 24 hours
  • Statistics showing lowest, average, and highest prices
  • Visual chart showing price distribution
  • Buy/Sell recommendations based on 6 cheapest and 6 most expensive hours
  • Both HTML and JSON API endpoints

Endpoints

  • / - Home page with all available endpoints
  • /prices - View all electricity prices (HTML)
  • /gemiddeld - View price statistics with chart (HTML)
  • /kopen - Check if current hour is good for buying (HTML)
  • /verkopen - Check if current hour is good for selling (HTML)
  • /api/prices - Get prices as JSON
  • /api/kopen - Get buying status as JSON
  • /api/verkopen - Get selling status as JSON
  • /health - Health check endpoint
  • /docs - Interactive API documentation (Swagger UI)

Running with Docker

Build and run using Docker:

docker build -t stroomprijs-api .
docker run -d -p 8000:8000 --name stroomprijs stroomprijs-api

Or use Docker Compose:

docker-compose up -d

Stop the container:

docker-compose down

View logs:

docker-compose logs -f

Running Locally (without Docker)

1. Create virtual environment:

python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

2. Install dependencies:

pip install -r requirements.txt

3. Run the application:

uvicorn main:app --reload

4. Access the application:

Open your browser and go to:

Docker Commands Reference

Build the image:

docker build -t stroomprijs-api .

Run the container:

docker run -d -p 8000:8000 --name stroomprijs stroomprijs-api

Stop the container:

docker stop stroomprijs

Start the container:

docker start stroomprijs

Remove the container:

docker rm stroomprijs

View container logs:

docker logs stroomprijs
docker logs -f stroomprijs  # Follow logs

Access container shell:

docker exec -it stroomprijs /bin/bash

Environment

The application uses the Amsterdam timezone (Europe/Amsterdam) for all time-based calculations.

API Response Examples

/api/kopen - Buy Status

{
  "status": "OK",
  "action": "kopen",
  "message": "Huidige uur is in de 6 goedkoopste uren - kopen aanbevolen",
  "current_hour": 3,
  "current_time": "2026-01-08 03:45:12"
}

/api/verkopen - Sell Status

{
  "status": "neutraal",
  "action": "verkopen",
  "message": "Neutraal - niks doen",
  "current_hour": 12,
  "current_time": "2026-01-08 12:30:45"
}

Technology Stack

  • FastAPI - Modern web framework
  • Uvicorn - ASGI server
  • Chart.js - Data visualization
  • EnergyZero API - Price data source
  • Python 3.11
  • Docker & Docker Compose

About

Stroomprijs bepaling Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors