Skip to main content

Simple API for gesetze-im-internet.de's xml readout

Project description

Gesetze-Im-Internet Python Package

PyPI - Downloads PyPI - Version PyPI - Python Version PyPI - License Pipeline

A simple API to access data from gesetze-im-internet.de

www.gesetze-im-internet.de offers an xml version of the laws for access by third parties. The xml toc can be found at https://www.gesetze-im-internet.de/gii-toc.xml, the links in it point to the various legal documents.

This package uses this feature to provide access to the individual laws, books, etc.

Installation

Install from pypi

pip install gesetze-im-internet

or compile yourself

git clone https://gitlab.com/Dacid99/gesetze-im-internet.git
pip install poetry
poetry install

Basic Usage

Table of Contents

Import the gesetze-im-internet table of contents to get access to the entire library

from gesetze_im_internet import toc

This object is your starting point for browsing and access all available law documents. For example:

>>> toc
Gesetze-im-Internet Inhaltsverzeichnis

>>> len(toc)
6450

>>> list(toc)
['Gesetz über die Ausprägung einer 1-DM-Goldmünze und die Errichtung der Stiftung "Geld und Währung"',
 'Erstes Gesetz zur Vereinheitlichung und Neuregelung des Besoldungsrechts in Bund und Ländern',
 ... ]

>>> toc[0]
Gesetz über die Ausprägung einer 1-DM-Goldmünze und die Errichtung der Stiftung "Geld und Währung"

>>> toc("Bürgerliches Gesetzbuch", validate=True)
Bürgerliches Gesetzbuch

With the Dokument object you get from indexing or calling the toc, you now have a complete law book at your disposal. All data is readonly. For complete information check out the source code either manually or with your favorite IDE's features.

bgb = toc("Bürgerliches Gesetzbuch")

>>> bgb
Bürgerliches Gesetzbuch

>>> str(bgb)


>>> len(bgb)
2831

>>> list(bgb)
["BGB Inhaltsübersicht",
 "BGB Buch 1 Allgemeiner Teil",
 "BGB Abschnitt 1 Personen",
 "BGB Titel 1 Natürliche Personen, Verbraucher, Unternehmer",
 "BGB § 1 Beginn der Rechtsfähigkeit",
 ... ]

>>> for norm in bgb:
...     print(norm)
BGB Inhaltsübersicht
BGB Buch 1 Allgemeiner Teil
BGB Abschnitt 1 Personen
BGB Titel 1 Natürliche Personen, Verbraucher, Unternehmer
BGB § 1 Beginn der Rechtsfähigkeit
...

>>> bgb[5]
BGB § 1 Beginn der Rechtsfähigkeit

>>> bgb(1)
BGB § 1 Beginn der Rechtsfähigkeit

>>> bgb.href
'https://www.gesetze-im-internet.de/bgb/index.html'

>>> bgb.ausfertigung_datum
datetime.datetime(1896, 8, 18, 0, 0, tzinfo=zoneinfo.ZoneInfo(key='Europe/Berlin'))

>>> bgb.standangabe_kommentar
"Neugefasst durch Bek. v. 2.1.2002 I 42, 2909; 2003, 738;"

>>> bgb.builddate
datetime.datetime(2025, 7, 22, 21, 55, 7, tzinfo=zoneinfo.ZoneInfo(key='Europe/Berlin'))

Iterating the Dokument instance yields Norm instances, holding the data of individual laws. You can access that data in a similar way.

>>> abschnitt = bgb[2]

>>> abschnitt
BGB Buch 1 Allgemeiner Teil

>>> abschnitt.is_gliederung
True

>>> abschnitt.gliederungsbez
Buch 1

>>> paragraph1 = bgb[5]
# The Dokument class also holds norms encoding gliederungsüberschriften.
# Therefore the indexes and paragraph numbers do not necessarily align.

>>> paragraph1 = bgb(1)

>>> paragraph1.is_gliederung
False

>>> paragraph1.nr
1.0

>>> int(paragraph1)
1

>>> float(paragraph1)
# This returns an float version of the alphanumeric notation (3b -> 3.02).
# To translate this you can use gesetze_im_internet.utils.float2alphanumeric
1.0

>>> paragraph1.href
'https://www.gesetze-im-internet.de/bgb/__1.html'

>>> for absatz in paragraph1:
...     print(absatz)
(1) Die Rechtsfähigkeit des Menschen beginnt mit der Vollendung der Geburt.

>>> paragraph1
'BGB § 1 Beginn der Rechtsfähigkeit'

>>> str(paragraph1)
(1) Die Rechtsfähigkeit des Menschen beginnt mit der Vollendung der Geburt.

>>> len(paragraph1)
1

>>> list(paragraph1)
[BGB § 1 Beginn der Rechtsfähigkeit I]

>>> bytes(paragraph1)
b'<norm builddate="20251013215507" doknr="BJNR001950896BJNE000102377"><metadaten><jurabk>BGB</jurabk><enbez>&#167; 1</enbez><titel format="parat">Beginn der Rechtsf&#228;higkeit ..."

>>> paragraph1.titel
'Beginn der Rechtsfähigkeit'

>>> paragraph1.enbez
'§ 1'

>>> paragraph1[0]
BGB § 1 Beginn der Rechtsfähigkeit Abs. 1
# If you prefer to use roman notation for Absätze,
# the helper *gesetze_im_internet.utils.int2roman* converts integers to that notation.

>>> paragraph1(1)
BGB § 1 Beginn der Rechtsfähigkeit Abs. 1

>>> paragraph1.dokument
Bürgerliches Gesetzbuch

In the same fashion that a document is split into norms, a norm is split in absätze, an absatz is made of sätze and a satz may have nummern. Please be aware that the logic for splitting into sätze is experimental and may yield faulty results.

Due to the complexity of the german language, further division into alternativen was not possible within the scope of this project.

Contributing

Everyone is invited to contribute to this project!

Just contact me or send me a merge request on gitlab.

Please make sure to read the contributing guideline and the development guide to get a headstart.

License

This software is licensed under the European Union Public License Version 1.1 . This a copyleft open-source license explicitly compatible with the GPL licenses, designed for legal security throughout the European Union member states.

Disclaimer

The authors of this software are not associated with the Bundesministerium für Justiz und Verbraucherschutz, which offers the gesetze-im-internet service. They have created the integration as open source in their spare time on the basis of publicly accessible information.

The output of this software may be flawed and can in no way be considered legal advice.

The use of the integration is at the user's own risk and responsibility. The developers are not liable for any damages arising from the use of the integration.

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

gesetze_im_internet-0.0.3.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

gesetze_im_internet-0.0.3-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file gesetze_im_internet-0.0.3.tar.gz.

File metadata

  • Download URL: gesetze_im_internet-0.0.3.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/5.15.154+

File hashes

Hashes for gesetze_im_internet-0.0.3.tar.gz
Algorithm Hash digest
SHA256 623d1f4c1ac00426177958440742c831f7e5b57803f5b8666e81a48aa18520b2
MD5 f079e590da6ba7c983dc8d570c0c81e4
BLAKE2b-256 30f9ff4d9e7eb0d2b9280d06144be992c40450658e146368f8b723ad273f460c

See more details on using hashes here.

File details

Details for the file gesetze_im_internet-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: gesetze_im_internet-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/5.15.154+

File hashes

Hashes for gesetze_im_internet-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b5bb83070e19a012d70e71416aa76e28478126cfe3be0496b096419206f68f93
MD5 6e4cce346cd8db625b7055a19903af38
BLAKE2b-256 a14fae6a598f54ccac6f3c8dcf5bb3cb2e60b05a813447174450c55b3f639ee6

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