Skip to main content

Client for Swiss parliament API

Project description

swissparlpy

Inspired by the R package swissparl, this module provides easy access to the data of the OData webservice of the Swiss parliament.

Table of Contents

Installation

swissparlpy is available on PyPI, so to install it simply use:

$ pip install swissparlpy

Usage

See the examples directory for more scripts.

Get tables and their variables

>>> import swissparlpy as spp
>>> spp.get_tables()[:5] # get first 5 tables
['MemberParty', 'Party', 'Person', 'PersonAddress', 'PersonCommunication']
>>> spp.get_variables('Party') # get variables of table `Party`
['ID', 'Language', 'PartyNumber', 'PartyName', 'StartDate', 'EndDate', 'Modified', 'PartyAbbreviation']

Get data of a table

>>> import swissparlpy as spp
>>> data = spp.get_data('Canton', Language='DE')
>>> data
<swissparlpy.client.SwissParlResponse object at 0x7f8e38baa610>
>>> data.count
26
>>> data[0]
{'ID': 2, 'Language': 'DE', 'CantonNumber': 2, 'CantonName': 'Bern', 'CantonAbbreviation': 'BE'}
>>> [d['CantonName'] for d in data]
['Bern', 'Neuenburg', 'Genf', 'Wallis', 'Uri', 'Schaffhausen', 'Jura', 'Basel-Stadt', 'St. Gallen', 'Obwalden', 'Appenzell A.-Rh.', 'Solothurn', 'Waadt', 'Zug', 'Aargau', 'Basel-Landschaft', 'Luzern', 'Thurgau', 'Freiburg', 'Appenzell I.-Rh.', 'Schwyz', 'Graubünden', 'Glarus', 'Tessin', 'Zürich', 'Nidwalden']

Release

To create a new release, follow these steps (please respect Semantic Versioning):

  1. Adapt the version number in swissparlpy/__init__.py
  2. Update the CHANGELOG with the version
  3. Create a pull request to merge develop into main (make sure the tests pass!)
  4. Create a new release/tag on GitHub (on the main branch)
  5. The publication on PyPI happens via GitHub Actions on every tagged commit

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

swissparlpy-0.1.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

swissparlpy-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: swissparlpy-0.1.1.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.26.0

File hashes

Hashes for swissparlpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d22787184a39866aac5b84e3b8256e17488ac91e2c72e9ba105c7eb903cd0ec8
MD5 e70d10e53efa712bd9990ba9ea035397
BLAKE2b-256 6976db9fc6f3c2a1853981ced56543b0fd5844c9a5c8ae2b6ce1f863b98ac984

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swissparlpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.26.0

File hashes

Hashes for swissparlpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e98e4272cff9bb9d20855c0f0f77fea05be4c32bc2087cd277ec715917cf236a
MD5 1568154ea59a349fff5eb57d59cc5dec
BLAKE2b-256 4cc64f2194e1b60ed73ed8e49ef188263448b9b2edd6a4dda87975fb4a9e7fa5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page