Skip to main content

Track petrol prices in Germany via the Tankerkönig-API, SQLite and PySide6-GUI

Project description

Benzintracker

A desktop application for fetching, storing and analysing fuel prices in your area – powered by the Tankerkönig API.

Python PySide6 License


Features

  • Map view – Nearby stations on an interactive map, filterable by fuel type
  • Price table – Sortable table of all stations with E5, E10 and Diesel prices; cheapest price per column is highlighted
  • Statistics – Four charts: price history, daily average, station comparison and time-of-day analysis; all exportable as PNG, PDF or SVG
  • CSV export – Export the price table as CSV (UTF-8 with BOM for Excel compatibility)
  • Automatic refresh – Configurable interval with random jitter as required by the Tankerkönig terms of use
  • Manual refresh – On demand via button, with a 2-minute cooldown between requests
  • Multiple locations – Save any number of locations, set one as default
  • System tray – Optionally keep running in the background; data continues to be fetched even when the window is closed
  • Light and dark theme – Native styling via Qt Fusion + QPalette
  • Multilingual – German and English included; additional languages can be added via a JSON file
  • Custom database path – The SQLite file can be placed on a network drive or any other location
  • Secure API key storage – Via the system-wide password manager (GNOME Keyring, KWallet, Windows Credential Manager, macOS Keychain)

Requirements


Installation

From PyPI

pip install benzintracker

From source

git clone https://github.com/your-name/benzintracker.git
cd benzintracker
pip install -e .

With optional developer dependencies

pip install -e ".[dev]"

Usage

benzintracker

First launch

  1. Enter your API key – Go to Settings → API Key, enter your Tankerkönig key and click "Save". The key is stored securely in the system-wide password manager.

  2. Set your location – Go to Settings → Location, enter your coordinates (latitude/longitude) and search radius, save the entry and set it as the default. You can look up your coordinates on maps.google.com or openstreetmap.org.

  3. Start the first fetch – The application automatically fetches data for the default location on startup.

API key via environment variable (optional)

# Linux / macOS
export TANKERKOENIG_API_KEY="your-api-key"

# Windows (PowerShell)
$env:TANKERKOENIG_API_KEY = "your-api-key"

Database

The SQLite database is stored in the platform-specific user data directory by default:

Platform Default path
Linux ~/.local/share/benzintracker/benzintracker.db
macOS ~/Library/Application Support/benzintracker/benzintracker.db
Windows C:\Users\<n>\AppData\Roaming\benzintracker\benzintracker.db

A custom path – for example on a network drive – can be set under Settings → Database. The change takes effect on the next application start.

Note: SQLite on network drives (NFS, SMB) works reliably but may be slower with poor connectivity. The application automatically retries write operations when a temporary lock is encountered.


Languages

Language files are located under benzintracker/locales/ as JSON files. To add a new language:

  1. Copy benzintracker/locales/en.json and rename it, e.g. fr.json
  2. Update the _meta block:
    "_meta": {
        "language": "Français",
        "locale": "fr",
        "author": "Your Name"
    }
    
  3. Translate all values
  4. Restart the application – the new language will appear automatically in the dropdown under Settings → Language

System tray

The tray mode can be enabled under Settings → System tray. When active, closing the window does not quit the application – it keeps running in the background and continues fetching data.

  • Left-click on the tray icon: show/hide the window
  • Right-click on the tray icon: context menu with "Show window" and "Quit"

Linux note: On GNOME version 40 and later, the extension AppIndicator and KStatusNotifierItem Support must be installed for the tray icon to be visible. On KDE, XFCE and Windows it works without any additional setup.


Project structure

benzintracker/
├── api/
│   ├── tankerkonig.py      # API client
│   └── service.py          # Connects API and database
├── database/
│   ├── db.py               # Connection, initialisation, retry logic
│   └── models.py           # CRUD operations
├── ui/
│   ├── main_window.py      # Main window, timer, tray
│   ├── styles.py           # QPalette light/dark
│   └── tabs/
│       ├── map_tab.py      # Map view (Folium + QWebEngineView)
│       ├── table_tab.py    # Price table
│       ├── stats_tab.py    # Statistics (Matplotlib)
│       └── settings_tab.py # Settings
├── locales/
│   ├── de.json             # German
│   └── en.json             # English
├── config.py               # Central configuration
├── settings.py             # Persistent settings (QSettings + keyring)
├── translator.py           # Runtime translation
└── main.py                 # Entry point

Dependencies

Package Purpose
PySide6 GUI framework
folium Map rendering (HTML/Leaflet)
matplotlib Statistics charts
numpy Trend line calculation
requests HTTP requests to the Tankerkönig API
platformdirs Platform-appropriate data paths
keyring Secure API key storage

License

MIT License

Copyright 2026 Frank Hoffmann

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

AI Usage

I used the AI assistant Anthropic Claude AI - Sonnet 4.6 to create this tool.

As a computer scientist, I have reviewed and approved every single line of code, and I understand the tool’s internal processes and how it works. I didn’t just copy and paste the code from the AI. Instead, I wrote it by hand, line by line, making changes whenever I deemed it necessary.

Nevertheless, there may still be errors or poor design choices. Everyone is free to examine, modify, improve, fork the code or call it AI slop :D

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

benzintracker-0.1.2.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

benzintracker-0.1.2-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file benzintracker-0.1.2.tar.gz.

File metadata

  • Download URL: benzintracker-0.1.2.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for benzintracker-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ffa5ad8a6cd8b5300d3f18db61ad503fafdf1d36895344d4a27bffde716e2d6f
MD5 47c0f69497f4795b8a157396d93ffbed
BLAKE2b-256 4b5038973c6d5c9630606812d52826c1e3d235c77bdab075c8b4ff4fdf8d688d

See more details on using hashes here.

File details

Details for the file benzintracker-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: benzintracker-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for benzintracker-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50b5bf98b2facde43c2811269b11aa6fd45b7942b18fa9ba6e2a4a5dddb71764
MD5 e712c62dcc727834fd32b6eb1966b77c
BLAKE2b-256 518d7f8d837e3f39bd3f30424e173a52fcf941e3572980adf1d377103191b5a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page