swissparlpy
swissparlpy is a Python module that provides easy access to the data of the OData webservice of the Swiss Parliament and the OpenParlData.ch REST API.

Quick Start
Current release: 2.0.0 – requires Python 3.10 or higher. See the changelog for all changes.
pip install swissparlpy
import swissparlpy as spp
# List available tables
tables = spp.get_tables()
print(tables[:5])
# ['MemberParty', 'Party', 'Person', 'PersonAddress', 'PersonCommunication']
# Get data from a table
councillors = spp.get_data('MemberCouncil', Language='DE', CantonAbbreviation='ZH')
for c in councillors[:10]:
print(f"{c['FirstName']} {c['LastName']}")
Features
- Multiple backends – Use the official parlament.ch OData API or the OpenParlData.ch REST API
- Simple API – Intuitive functions to list tables, inspect variables, and query data
- Filtering – Filter data by any field, substring, date range, or advanced OData filter expressions
- Pagination – Automatically handles large result sets with server-side pagination
- pandas integration – Convert results directly to a
DataFramewith.to_dataframe() - Visualization – Plot voting results directly with the optional visualization support
Vizualization of voting results as scoreboard:
Credits
This library is inspired by the R package swissparl by David Zumbach. The idea for a Python version was triggered by Ralph Straumann asking on Twitter.
Similar Libraries
| Language | Library |
|---|---|
| R | zumbov2/swissparl |
| JavaScript | michaelschoenbaechler/swissparl |