A package which implements functionality to download and parse german legal texts.
Project description
GermanLegalTexts
A Python package for downloading, parsing, and working with German legal texts and court judgements from official German government sources.
Description
GermanLegalTexts provides tools to programmatically access and work with German legal texts and court judgements. It allows you to:
-
Law Books (Gesetzbücher): Download and parse legal codes from Gesetze im Internet
- Download individual law books by URL
- Download all available German legal texts (sync or async)
- Access specific paragraphs, sections, and other elements
-
Court Judgements (Rechtsprechung): Download and parse court decisions from Rechtsprechung im Internet
- Download individual judgements
- Browse and filter the judgement index
- Download the first n judgements or all available judgements (sync or async)
- Access structured judgement data (facts, reasoning, decision)
Both downloaders support an async API built on httpx that streams results as they complete, with configurable rate limiting.
Installation
Requires Python 3.12 or higher.
pip install germanlegaltexts
Usage
Law Books (Gesetzbücher)
from germanlegaltexts.GermanLawDownloader import GermanLawDownloader
downloader = GermanLawDownloader()
# Download a single law book
bgb = downloader.download_law_book("https://www.gesetze-im-internet.de/bgb/xml.zip")
paragraph = bgb.get_paragraph("§ 242")
if paragraph:
print(paragraph.metadaten.titel)
print(paragraph.textdaten.text.content.text)
Court Judgements (Rechtsprechung)
from germanlegaltexts.GermanJudgementDownloader import GermanJudgementDownloader
downloader = GermanJudgementDownloader()
# Download the first 10 judgements
for judgement in downloader.download_first_n_judgements(10):
print(f"{judgement.aktenzeichen} — {judgement.doktyp}")
Async batch downloads
Both downloaders expose async generator methods that start downloads in parallel and yield results as they arrive, with a configurable rate limit (default: 1 new request per second).
import asyncio
from germanlegaltexts.GermanLawDownloader import GermanLawDownloader
from germanlegaltexts.GermanJudgementDownloader import GermanJudgementDownloader
async def main():
# Stream all law books — start 2 new downloads per second
law_downloader = GermanLawDownloader()
async for book in law_downloader.iter_all_law_books(max_per_second=2.0):
print(book.norms[0].metadaten.jurabk)
# Stream the first 100 judgements with no throttle
judgement_downloader = GermanJudgementDownloader()
async for judgement in judgement_downloader.iter_first_n_judgements(100, max_per_second=None):
print(f"{judgement.aktenzeichen} — {judgement.gertyp}")
asyncio.run(main())
Set max_per_second=None to start all downloads immediately without any rate limiting.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Data source: Gesetze im Internet
- Data source: Rechtsprechung im Internet
- Author: Malte Weber
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
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 germanlegaltexts-0.4.1.tar.gz.
File metadata
- Download URL: germanlegaltexts-0.4.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdf421a00699df089cb171e75fef03b7e3dff32cad6138a00e584c78e5e01493
|
|
| MD5 |
9d1c21539e912a9b1ee8fe2b595a5324
|
|
| BLAKE2b-256 |
28b6dbbf335f5ca83b22b84eb4f1c65454b2c636d74c5f0781b6ca081a1192f0
|
File details
Details for the file germanlegaltexts-0.4.1-py3-none-any.whl.
File metadata
- Download URL: germanlegaltexts-0.4.1-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a46b1e301b3679539bc57c53385baa2e68e8921b8e908bf0df6bee6e9920ee2
|
|
| MD5 |
311ccb80cb17dddfa35bb9ee1d5b95f6
|
|
| BLAKE2b-256 |
490c288ac4b4fc801153f73d3f3da9d3782bb680e6df2afe61a46a1950a68dff
|