Skip to main content

Python wrapper for the Austrian Parliament open data API

Project description

atparlpy

This project provides a Python wrapper for the Austrian Parliament's Open Data REST APIs. The API responses are available both as dataclasses and as Pandas Dataframes.

Installation

atparlpy is availalbe on PyPI and can be installed via pip:

$ pip install atparlpy

Usage

The atparlpy module exposes each dataset as a separate class. Import and instantiate the class for your desired dataset. For example, to get all Inquiries ("Parlamentarische Anfragen") in the 28. legislative period:

>>> from atparlpy import Inquiries
>>> inquiries = Inquiries(gp=28, nrbr="NR").AsList()
>>> print(len(inquiries))
>>> print(inquiries[0].betreff)

To get the result as a Pandas DataFrame instead, use the AsDataFrame() method:

>>> from atparlpy import Inquiries
>>> df = Inquiries(gp=28, nrbr="NR").AsDataFrame()
>>> print(df['status'].value_counts())
>>> df.to_csv('inquiries.csv', index=False)

All filters can be set either via the constructor or via the fluent setters. For example:

>>> from atparlpy import Inquiries
>>> inquiries = Inquiries().gp(28).nrbr("NR").AsList()

For API responses which link to a details or history page, the wrapper classes expose a GetDetails() method, which fetches the json representation of the respective details or history page. The references and names of the details / history page are wrapped explicitly for easy access. The meta and content properties are available as raw dictionaries. For example:

>>> reports = CommitteeReports(nrbr="NR", gp_code="XXV").AsList()
>>> details = reports[0].GetDetails()
>>> description = details.content['description']
>>> initiators = list(filter(lambda n: n.funktext == 'Eingebracht von', details.names))

See examples.py for more examples.

Convenience features

  • Wherever the REST API only accepts the legislative period as a Roman numeral ("GP_CODE": ["XXVIII"]), the wrapper also accepts the corresponding integer value. The Roman numeral can be set via gp_code and the integer value via gp. If both are provided, gp_code takes precedence.
  • The wrapper accepts either a list of strings or a single string value wherever the REST API only accepts a list of string values (e.g., "THEMEN": ["Arbeit"] can be set as .themen("Arbeit") or .themen(["Arbeit"])).

Supported datasets

Anträge (Motions)

# Beispiel: Abfrage nach allen Anträgen im Nationalrat während der XXVII. GP zum Thema Arbeit
motions = Motions(gp_code="XXVII").nrbr("NR").themen(["Arbeit"]).AsList()

Ausschussberichte (CommitteeReports)

# Beispiel: Alle Ausschussberichte im Nationalrat in der XXV. Gesetzgebungsperiode zum Thema Arbeit
reports = CommitteeReports(nrbr="NR", gp_code="XXV", themen="Arbeit").AsList()

Beschlüsse (Resolutions)

# Beispiel: Alle Beschlüsse im Nationalrat während der 25. GP zum Thema Kultur
resolutions = Resolutions().nrbr("NR").gp_code("XXV").themen("Kultur").AsList()

Parlamentarische Anfragen (Inquiries)

# Beispiel: Alle parlamentarischen Anfragen im Nationalrat während der XXVIII. GP zum Thema Arbeit oder Bildung
inquiries = Inquiries(gp_code="XXVIII", nrbr="NR").themen(["Arbeit", "Bildung"]).AsList()
# Beispiel: Alle parlamentarischen Anfragen im Bundesrat während der 27. GP
inquiries = Inquiries(gp=27, nrbr="BR").AsList()

Aktuelle Abgeordnete zum Nationalrat und Mitglieder des Bundesrats (Parliamentarians)

# Beispiel: Alle aktuellen Abgeordneten zum Nationalrat
members_of_parliament = Parliamentarians(nrbr="NR").AsList()

# Beispiel: Fraktionen im Nationalrat plus Anzahl der Abgeordneten
df = Parliamentarians(nrbr="NR").AsDataFrame()
print(df['sort_wp'].value_counts())

# Beispiel: Aktuelle/r Präsident/in des Nationalrats
president = Parliamentarians(nrbr="NR").funk("1PNR").AsList()[0]
print(f"Präsident des NR: {president.name}")

# Beispiel: Alle aktuellen Mitglieder des Bundesrats
members_of_the_national_council = Parliamentarians(nrbr="BR").AsList()

The GetDetails() method of a MemberOfParliament or MemberOfTheNationalCouncil object fetch the details of the respective person, and return Person object. For example:

person = Parliamentarians(nrbr="NR").funk("1PNR").AsList()[0].GetDetails()
print(f"Link zum Foto: {person.image}")
print(f"Sitzplatz: {person.sitzplatz}")

Plenarsitzungen (PlenarySessions)

# Beispiel: Alle Plenarsitzungen des Nationalrats in der 28. GP
sessions = PlenarySessions(nrbr="NR",gp=28).AsList()
print(f"{len(sessions)} Sitzungen des Nationalrats gefunden")

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

atparlpy-0.1.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

atparlpy-0.1.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file atparlpy-0.1.1.tar.gz.

File metadata

  • Download URL: atparlpy-0.1.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for atparlpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 457e03d77c0b8a304a857439982036ef83b886058a76e2db395e23667ee571b1
MD5 95b3c8844bf507187e743f45eff3c4b1
BLAKE2b-256 4553fe4ce11a35397e3edf8b623fe6c0d7ccfdd778b59966fe481c773c5139ba

See more details on using hashes here.

File details

Details for the file atparlpy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: atparlpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for atparlpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 07c4ca26495b9867c6978e325efb8184b90a63a9e294f21c572d25df78566c77
MD5 fcd98f71691b684d07c3bbd669a22e9c
BLAKE2b-256 8db98cf07288bd8ee3d4d86f39d11e6b58c83b809dbb8e69ea5b2b91afec0277

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