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.3.0.tar.gz (15.4 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.3.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: germanlegaltexts-0.3.0.tar.gz
  • Upload date:
  • Size: 15.4 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.3.0.tar.gz
Algorithm Hash digest
SHA256 202f0207141c010032b9f33d12128e004d777bc6509a3c5b23f1c4c472f63ab9
MD5 c56e221e6164749f89570ad8536e0bc6
BLAKE2b-256 07e4e5eba296aac6176cd48309f9334450d3a3b851379f642f5284492a71c986

See more details on using hashes here.

File details

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

File metadata

  • Download URL: germanlegaltexts-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b40ac857829fc470d5365e16f533ecfa7d220122dc425de8613171a879f11680
MD5 4721551a37c234210fd446d7a4022928
BLAKE2b-256 b82f944414187da2ae68bb944e7acbe47b88ca92d9136e06b4069f27b43c914f

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