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")
Metadata
Release files for atparlpy 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| atparlpy-0.1.2.tar.gz | 14.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| atparlpy-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.4 kB
Release files / atparlpy-0.1.2.tar.gz
| Download URL | atparlpy-0.1.2.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f573271ac5898ba7b7961689fb7c3be5f241720c4841349b230e2c69b4381807
|
|
BLAKE2b-256 checksum How to use checksums |
f2e329642491d04a1329d1617928104983f91a5a1b10f737fe6c372f17b8252e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / atparlpy-0.1.2-py3-none-any.whl
| Download URL | atparlpy-0.1.2-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5f901cbec064b36c6bd5159ca2bea9c0fa9ff23202d94d6c1d769ae53de6511
|
|
BLAKE2b-256 checksum How to use checksums |
88152c26c11d5189f71323950b1b42a946730cae4b0287791f431d8c32f5421e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for atparlpy 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.