A Python client for accessing vnbdigital.de grid operator data via GraphQL
Project description
vnbdigital-client
A Python client library and CLI tool for accessing vnbdigital.de grid operator (Verteilnetzbetreiber) data. This package abstracts the GraphQL API and provides a simple, intuitive interface for looking up operators by their BDEW code.
Features
- Simple Python API for vnbdigital.de grid operator data
- Command-line interface (CLI) for quick lookups
- Unified search API matching the vnbdigital.de website (search for postcodes, operators, regions)
- Direct postcode-based and coordinate-based network operator search
- Typed dataclasses (
Operator,Region,Postcode,SearchResult) for structured results - Batch lookups for multiple operators
- Built with modern Python tooling (uv, pyproject.toml)
- Dev container support for easy development
- Comprehensive test coverage
Installation
From PyPI (when published)
pip install vnbdigital-client
Oder mit uv:
uv add vnbdigital-client
From source with uv
# Clone the repository
git clone https://github.com/the78mole/vnbdigital-client.git
cd vnbdigital-client
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Run directly (uv creates the venv and installs dependencies automatically)
uv run vnbdigital --help
Usage
Python API
from vnbdigital_client import VNBDigitalClient
client = VNBDigitalClient()
# Look up a grid operator by BDEW code / ID
operator = client.get_operator("179")
if operator:
print(f"{operator.name} - {operator.postcode} {operator.city}")
print(f"Website: {operator.website}")
for region in operator.regions:
print(f" Region: {region.name}")
# Get detailed information (types, description, services, documents, ...)
details = client.get_operator_details("179")
if details:
print(f"Typ: {', '.join(details.types)}")
print(f"Beschreibung: {details.description}")
print(f"Aufrufe: {details.clicks}")
# Batch lookup for multiple operators
results = client.get_operators(["179", "180", "181"])
for oid, op in results.items():
if op:
print(f"[{oid}] {op.name}")
else:
print(f"[{oid}] not found")
# Unified search (same API as vnbdigital.de website)
# Search for postal codes, operators, regions, locations, etc.
search_results = client.search("91058")
for result in search_results:
print(f"{result.type}: {result.title} - {result.subtitle}")
# Get network operators for a POSTCODE result
postcode_hit = next(r for r in search_results if r.type == "POSTCODE")
detail = client.search_by_postcode(postcode_hit.id)
for vnb in detail.get("vnbs", []):
print(f" - {vnb['name']}")
# Get network operators for a LOCATION result (coordinates lookup)
location_hit = next(r for r in search_results if r.type == "LOCATION")
# Extract coordinates from URL: /overview?coordinates=lat,lon&searchType=LOCATION
coords = location_hit.url.split("coordinates=")[1].split("&")[0]
detail = client.search_by_coordinates(coords)
for vnb in detail.get("vnbs", []):
print(f" - {vnb['name']}")
Command-Line Interface
The package includes a CLI tool for easy command-line access:
# Basic operator lookup
vnbdigital operator 179
# Detailed information
vnbdigital details 179
# JSON output
vnbdigital operator 179 --format json
# Batch lookup
vnbdigital batch 179 180 181
# Unified search (same as vnbdigital.de website)
# Search for postal codes, operators, regions, etc.
vnbdigital search 90158
vnbdigital search "Stadtwerke"
# Search with details for postcode and location results
vnbdigital search 90158 --details
# Search with JSON output
vnbdigital search 90158 --format json
# Look up network operators by geographic coordinates (lat,lon)
vnbdigital coordinates "49.5510,11.1101"
# Coordinates with JSON output
vnbdigital coordinates "49.5510,11.1101" --format json
# Coordinates with custom voltage filter
vnbdigital coordinates "49.5510,11.1101" --voltage Niederspannung
# Override API URL via environment variable
export VNBDIGITAL_API_URL="https://www.vnbdigital.de/gateway/graphql"
vnbdigital operator 179
Development
Using Dev Container
This project includes a dev container configuration for easy development:
- Open the project in VS Code
- Install the "Dev Containers" extension
- Click "Reopen in Container" when prompted
- The workspace is mounted into the container automatically
- When you run the first
uvcommand, it will create a.venvand install dependencies
Manual Setup
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Run tests (uv automatically creates a .venv and installs all dependencies)
uv run --extra dev pytest
# Run linting
uv run --extra dev ruff check src/
# Format code
uv run --extra dev black src/
# Type checking
uv run --extra dev mypy src/vnbdigital_client/
Running Tests
# Run all tests
uv run --extra dev pytest
# Run with coverage
uv run --extra dev pytest --cov=vnbdigital_client --cov-report=html
# Run specific test file
uv run --extra dev pytest tests/test_client.py
Project Structure
vnbdigital-client/
├── .devcontainer/ # Dev container configuration
│ ├── Dockerfile
│ └── devcontainer.json
├── .github/
│ └── workflows/ # GitHub Actions workflows
│ ├── ci.yml # Continuous integration
│ └── publish.yml # PyPI publishing
├── src/
│ └── vnbdigital_client/ # Main package
│ ├── __init__.py
│ ├── client.py # API client
│ └── cli.py # CLI tool
├── tests/ # Test suite
│ ├── test_client.py
│ └── test_cli.py
├── pyproject.toml # Project configuration
├── renovate.json # Renovate config
└── README.md
Configuration
Environment Variables
VNBDIGITAL_API_URL: GraphQL endpoint URL (default: https://www.vnbdigital.de/gateway/graphql)
Renovate
This project uses Renovate for automated dependency updates. Configuration is in renovate.json.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Daniel Glaser
Acknowledgments
- Built with uv - A fast Python package installer
- CLI built with Click
- Data provided by vnbdigital.de
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vnbdigital_client-0.1.3.tar.gz.
File metadata
- Download URL: vnbdigital_client-0.1.3.tar.gz
- Upload date:
- Size: 95.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
862e911507c8d8dc54864db72e72efc9978663f226b9aebc66f8cda8daacf627
|
|
| MD5 |
9fc4e215290d677d86858fc7df4cef8b
|
|
| BLAKE2b-256 |
bf631ab0cf34b7b4cfdad35be45f992d15a52d68b9a24ab8ea7caa41a9c579e6
|
Provenance
The following attestation bundles were made for vnbdigital_client-0.1.3.tar.gz:
Publisher:
publish.yml on the78mole/vnbdigital-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vnbdigital_client-0.1.3.tar.gz -
Subject digest:
862e911507c8d8dc54864db72e72efc9978663f226b9aebc66f8cda8daacf627 - Sigstore transparency entry: 1575272878
- Sigstore integration time:
-
Permalink:
the78mole/vnbdigital-client@57a548ae4f70a2aea5592a80b30d958aa294b63a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/the78mole
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57a548ae4f70a2aea5592a80b30d958aa294b63a -
Trigger Event:
push
-
Statement type:
File details
Details for the file vnbdigital_client-0.1.3-py3-none-any.whl.
File metadata
- Download URL: vnbdigital_client-0.1.3-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
212c949934afba5eece82d5539be9b40050b61701db88d8b31df862cca52eeae
|
|
| MD5 |
821065b81b9ecde28721426e02032186
|
|
| BLAKE2b-256 |
3a9896ce547da9c88e22bf30d8da695019b25dc04d7be18b436e034ba796dc78
|
Provenance
The following attestation bundles were made for vnbdigital_client-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on the78mole/vnbdigital-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vnbdigital_client-0.1.3-py3-none-any.whl -
Subject digest:
212c949934afba5eece82d5539be9b40050b61701db88d8b31df862cca52eeae - Sigstore transparency entry: 1575272929
- Sigstore integration time:
-
Permalink:
the78mole/vnbdigital-client@57a548ae4f70a2aea5592a80b30d958aa294b63a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/the78mole
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57a548ae4f70a2aea5592a80b30d958aa294b63a -
Trigger Event:
push
-
Statement type: