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 viagp_codeand the integer value viagp. If both are provided,gp_codetakes 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 fetches the details of the respective person, and returns a 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
Release history Release notifications | RSS feed
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 atparlpy-0.1.2.tar.gz.
File metadata
- Download URL: atparlpy-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f573271ac5898ba7b7961689fb7c3be5f241720c4841349b230e2c69b4381807
|
|
| MD5 |
6f2546e2ef4625e3ec0199f63466c7ca
|
|
| BLAKE2b-256 |
f2e329642491d04a1329d1617928104983f91a5a1b10f737fe6c372f17b8252e
|
File details
Details for the file atparlpy-0.1.2-py3-none-any.whl.
File metadata
- Download URL: atparlpy-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5f901cbec064b36c6bd5159ca2bea9c0fa9ff23202d94d6c1d769ae53de6511
|
|
| MD5 |
9f9e1811cbc64c77acf41a48ba10560a
|
|
| BLAKE2b-256 |
88152c26c11d5189f71323950b1b42a946730cae4b0287791f431d8c32f5421e
|