datapass
A fast, lightweight CLI tool to fetch and display mobile data usage from datapass.de (Telekom prepaid data monitoring).
Features
- 📊 Multiple output formats: Human-readable, JSON, or single values
- 🎨 Colored output: Optional ANSI color support
- 📈 Progress bar: Visual representation of data usage
- 🔄 Watch mode: Auto-refresh TUI dashboard
- 🚀 Fast and lightweight: Self-contained binary with minimal dependencies
- 🔒 Secure: Uses rustls for TLS (no OpenSSL runtime dependency)
- 🌍 Cross-platform: Works on Linux, macOS, and more
Important Note
Network Requirement: The datapass.de website is designed to be accessed from within the Telekom mobile network. When running the tool:
Option 1: Run on Telekom mobile network
# Works automatically when connected via Telekom mobile data
Option 2: Use with saved HTML file (for testing)
# Save the page from your browser while on Telekom network, then:
Option 3 (Advanced): Custom cookies
If you need to use specific cookies for authentication, you can provide them:
Installation
Using Nix (recommended)
# Run directly
# Install to profile
# Build from source
Using Cargo
From Source
# Binary will be at target/release/datapass
Install Shell Completions and Man Page
# Install shell completions (bash, zsh, fish)
# Install man page
# Or generate them manually
Usage
Basic Usage
# Display human-readable output with progress bar
# With colors
Output Formats
# JSON output
# Single values (useful for scripting)
Watch Mode (TUI Dashboard)
# Refresh every 60 seconds
# Refresh every 5 minutes
The TUI dashboard displays:
- Plan name and validity date
- Data usage statistics with colored indicators
- Visual progress gauge
- Auto-refresh countdown
Controls:
- Press
qorESCto quit - Press
rto refresh immediately
Advanced Options
# Use custom URL
# Read from local HTML file (for testing)
# Enable verbose logging
# Log to file
Example Output
Human-readable format
Plan: MagentaMobil Prepaid L
Valid until: 12. February 2026
Used: 12.64 GB (24.78%)
Total: 51.00 GB (100%)
Remaining: 38.36 GB (75.22%)
████████████████████████▓░░░░░░░░░░░░░░ 24.78%
JSON format
Development
Prerequisites
- Nix with flakes enabled, or
- Rust 1.70+ with Cargo
Using Nix
# Enter development shell (automatically installs pre-commit hooks)
# Build
# Run tests
# Run all checks
# Format code
Pre-commit Hooks
The project uses git-hooks.nix to automatically run checks before commits:
- Formatters: rustfmt, alejandra (Nix), prettier, taplo (TOML)
- Linters: clippy, deadnix, statix
- Tests: cargo test
The hooks are automatically installed when you enter the Nix development shell with nix develop. They will run automatically before each commit to ensure code quality and catch issues early.
Using Cargo
# Build
# Run tests
# Run with example file
# Run linter
# Format code
Project Structure
datapass/
├── src/
│ ├── main.rs # Entry point
│ ├── lib.rs # Library interface
│ ├── cli.rs # CLI argument parsing
│ ├── parser.rs # HTML parsing logic
│ ├── fetcher.rs # HTTP fetching
│ ├── display.rs # Output formatting
│ ├── tui.rs # TUI implementation
│ ├── types.rs # Data types
│ └── error.rs # Error types
├── tests/
│ └── integration_tests.rs
├── test/
│ └── Data usage - MagentaMobil Prepaid L.html
├── Cargo.toml
├── flake.nix
└── README.md
Testing
# Run all tests
# Run with verbose output
# Run specific test
Docker
Build and load locally
|
Note: Use
--network hostso the container shares the host's network stack. Telekom's datapass.de detects the mobile network by IP address — Docker's default bridge NAT breaks this detection.
Publish to Docker Hub
|
skopeo is available in the Nix dev shell (nix develop).
Using a local HTML file inside the container
Cross-Compilation
Using Nix, you can easily build for multiple platforms:
# Build for x86_64 Linux
# Build for aarch64 Linux
# Build for macOS (Intel)
# Build for macOS (Apple Silicon)
CI/CD
The project includes comprehensive GitHub Actions workflows that:
- ✅ Run all tests
- ✅ Check code formatting (rustfmt, alejandra for Nix)
- ✅ Run Clippy lints
- ✅ Check for dead Nix code (deadnix)
- ✅ Run Nix lints (statix)
- ✅ Build for multiple platforms
- ✅ Create releases with binaries for all platforms
Language Support
The tool supports both German and English formats:
- Numbers:
38,36 GB(German) and38.36 GB(English) - Automatically handles both comma and period decimal separators
- Works with German (
Datennutzung) and English (Data usage) page titles
Use Cases
Scripting
#!/bin/bash
# Alert when data usage exceeds 80%
USAGE=
if ; then
fi
Status Bar Integration
# i3status, polybar, etc.
Monitoring
# Log usage every hour
while ; do
done
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.