get_data2: Retrieve data from the OpenParlData.ch REST API

View source: R/get_data.R

get_data2R Documentation

Retrieve data from the OpenParlData.ch REST API

Description

get_data2 retrieves data from the OpenParlData.ch REST API for a given resource.

Usage

get_data2(table, max_rows, package_size = 1000, silent = FALSE, ...)

Arguments

table

name of the OpenParlData resource to download. For an overview of available endpoints use get_tables2().

max_rows

maximum number of rows to return. If omitted, all available rows matching the query are downloaded.

package_size

number of rows to download per request (mapped to the API parameter limit). Default is 1000. If the result set exceeds package_size, multiple requests are made using the API's pagination links.

silent

if TRUE, no progress bar and messages are displayed.

...

additional query parameters passed to the OpenParlData endpoint as URL query parameters. Common parameters include:

  • search: search query string.

  • search_mode: one of "partial" (default), "exact", "natural", "boolean".

  • search_scope: where to search

  • search_language: language-specific search (de, fr, it, rm, en).

  • sort_by: field(s) to sort by; prefix with - for descending.

Resource-specific filters (e.g. body_key, lang, etc.) can also be supplied. Multiple values can be provided as an R vector and are encoded as a comma-separated query value (e.g. body_key = c("AI", "AR")).

Value

A tibble containing up to max_rows records. Column composition depends on the selected resource and query parameters.

Examples

## Not run: 
# Retrieve first 10 persons
get_data2("persons", max_rows = 10)

# Retrieve a specific person by first and last name
get_data2(
  "persons",
  firstname = "Karin",
  lastname = "Keller-Sutter"
)

# Partial search (default mode) in affairs
get_data2("affairs", max_rows = 10, search = "Budget", search_mode = "partial")

# Boolean search with grouping (note: '&' is an operator in boolean mode)
get_data2(
  "affairs",
  max_rows = 10,
  search = "(Klima | Umwelt) & Schweiz",
  search_mode = "boolean"
)

# Combine search with scope/language and sorting
get_data2(
  "affairs",
  max_rows = 10,
  search = "Bundesrat Parlament",
  search_mode = "natural",
  search_language = "de",
  sort_by = "-begin_date"
)



## End(Not run)

swissparl documentation built on March 4, 2026, 9:07 a.m.