Skip to main content

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

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

germanlegaltexts-0.4.0.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

germanlegaltexts-0.4.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file germanlegaltexts-0.4.0.tar.gz.

File metadata

  • Download URL: germanlegaltexts-0.4.0.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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

Hashes for germanlegaltexts-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2b82342a9d110605683f7d2238e4a4ca9b2be8fafb7e5b88d6680bd9aa3ecbbd
MD5 0928a2607d562b0c40bb8d97f1f0ba12
BLAKE2b-256 b3d81dfdc4c7d5ffd945c2618ae29cea6d530aa4d1e7afcec4edcb3b0c7fb8da

See more details on using hashes here.

File details

Details for the file germanlegaltexts-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: germanlegaltexts-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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

Hashes for germanlegaltexts-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93c72fe48cebdd992ce5cd8a0f77ad7d67b276077bae68f9c8496214c6ea2057
MD5 b142a516dd4d847e67eabb700f119c45
BLAKE2b-256 77712ea0d5dabe12dc63eea5b2a375cb0ab775a46816f0f191492a7d478186f9

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