Skip to main content

Python Wrapper for the Bundestags API

Project description

BundestagsAPy: A python wrapper for the Bundestags DIP API.

Installation

The easiest way to install the latest stable version from PyPI is by using pip:

pip install bundestagsapy

Alternatively, install directly from the GitHub repository:

pip install git+https://github.com/parobo/BundestagsAPy

Usage

To use the API wrapper, simply call the client object with your API key. See https://dip.bundestag.de/%C3%BCber-dip/hilfe/api#content on how to get an API key.

Initialization

import BundestagsAPy
api_key='XXXXXXXXXXXXXXX'
client = BundestagsAPy.Client(api_key)

Endpoints

The client provides access to all available documents through methods named after the endpoints (bt_{endpoint}). E.g.

client.bt_aktivitaet(max_results=50, id, start_date, end_date, updated_start, updated_end, drucksache, plenaeprotokoll, zuordnung)

The available endpoint are:

  • aktivitaet: bt_aktivitaet()
  • drucksache: bt_drucksache()
  • drucksache-text: bt_drucksache_text()
  • person: bt_person()
  • plenarprotokoll: bt_plenarprotokoll()
  • plenarprotokoll-text: bt_plenarprotokoll_text()
  • vorgang: bt_vorgang()
  • vorgangsposition: bt_vorgangsposition()

All methods accept max_results as input. It takes either an interger as value, in which case the method returns the first max_results supplied by the API, or False, in which case all available documents are returned. Note that because of the API infrastructure, at least 50 results are always returned.

id can either be an integer (for single document returned) or a list of integers (for multiple).

Most endpoints accept the parameters start_date and end_date, which should be in strings in the format YYYY-mm-dd. Some deviation is allowed, the client tries to parse the date using dateutil and then formats it however necessary for the API.

The client now also accept the parameters updated_start and updated_end, which should be in strings in the format YYYY-mm-ddTHH:MM:SS+ZZ:ZZ. Some deviation is allowed, the client tries to parse the date using dateutil and then formats it however necessary for the API. Default time zone is +02:00.

see https://dip.bundestag.de/documents/informationsblatt_zur_dip_api.pdf for details on other acceptable parameters for each endpoint. For more information on available endpoints and allowed parameters, see also https://search.dip.bundestag.de/api/v1/swagger-ui/.

Results

The results from each request to an endpoint is an object named after the document requested if a single document was requested. Each object has as its attributes all the available data named in the same way as documented on https://dip.bundestag.de/documents/informationsblatt_zur_dip_api.pdf.

If multiple documents were requested, BundestagsAPy returns a list of the documents. E.g.

for result in client.bt_aktivitaet(max_results=False, start_date='2020-01-01',end_date='2020-01-02'):
	print(result.id,result.titel)

for result in client.bt_drucksache(max_results=False, updated_start='2022-01-01T00:00:00+02:00',updated_end='2023-02-01T00:00:00+02:00'):
	print(result.id,result.titel)

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

BundestagsAPy-1.4.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file BundestagsAPy-1.4.tar.gz.

File metadata

  • Download URL: BundestagsAPy-1.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for BundestagsAPy-1.4.tar.gz
Algorithm Hash digest
SHA256 f07602c98e1d2f063d4244d2c612a164e0eeccbed353a86e0baea89e693fa788
MD5 1980cae0ac8f1aa8da339dbd916c69ea
BLAKE2b-256 2b7350774a4a5481d4d6983d5c485b5fef89607567ba96440f81531f625ed837

See more details on using hashes here.

Supported by

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