Learn R Programming

⚠️There's a newer version (0.4.1) of this package.Take me there.

stortingscrape

stortingscrape is an R package for retrieving data from the Norwegian parliament (Stortinget) through their easily accessible back-end API. The data requested using the package require little to no further structuring. The scope of the package ranges from general data on the parliament itself (rules, session info, committees, etc) to data on the parties, bibliographies of the MPs, questions, hearings, debates, votes, and more.

The main goal of stortingscrape is to allow researchers to access any data from the Norwegian parliament easily, but also still be able to structure the data according to ones need. Most importantly, the package is facilitated for weaving together different parts of the data.stortinget.no API.

Installation

Because I’m not in control of the API itself, the CRAN package might at times be outdated. Submitting to CRAN is quite time consuming and will not be done more than once or twice a year.

CRAN (stable version)

The latest stable version of the stortingscrape package can be installed from by running CRAN:

install.packages("stortingscrape")

Github (development version)

The development version of the package can be installed either by cloning this repository and building the package in R or by installing via the devtools::install_github() function:

devtools::install_github("martigso/stortingscrape")
library(stortingscrape)

Usage examples

Request all interpellations for a parliamentary session:

library(stortingscrape)

parl_sessions |> # sessions data are built into the package
  head()         # but can also be retrieved with `get_parlsessions()`


qsesh <- get_session_questions(parl_sessions$id[4], q_type = "interpellasjoner")

int1213 <- list()

for(i in qsesh$id) {
  
  message("Getting ", i)
  
  int1213[[i]] <- get_question(i, good_manners = 2)

}

int1213 <- do.call(rbind, int1213)

head(int1213)

Get biographies of all MPs for a given parliamentary period (will take ~30min to run):

parl_periods # parliamentary periods (4 years) are built into the package,
             # but can also be retrieved with `get_parlperiods()`

mps <- get_parlperiod_mps(parl_periods$id[1], substitute = TRUE)

mps_bios <- lapply(mps$mp_id, get_mp_bio, good_manners = 2)

# Expand by all periods the MP has been in parliament
mps_periods <- lapply(mps_bios, function(x){
  
  data.frame(x$root,
             x$parl_periods)

})

mps_periods <- do.call(rbind, mps_periods)

# Expand by all positions held in parliament
mps_positions <- lapply(mps_bios, function(x){
  
  if(nrow(x$parl_positions) < 1) return()
  
  data.frame(x$root,
             x$parl_positions)
  
})

mps_positions <- do.call(rbind, mps_positions)

Data description

The back-end data is described in detail in the API of Stortinget.

Functions

You can find a list of all functions here.

Citation

Please use the following citation when using the package in research:

Søyland M (2024). “stortingscrape: An R package for accessing data from the Norwegian parliament.” URL: https://martigso.github.io/stortingscrape/articles/stortingscrape.html.

This can, as with all R-packages, also be generated using the citation function:

citation("stortingscrape")

Copy Link

Version

Install

install.packages('stortingscrape')

Monthly Downloads

154

Version

0.4.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Martin S<c3><b8>yland

Last Published

March 7th, 2025

Functions in stortingscrape (0.4.0)

get_mp_pic

Retrieve picture of specific MPs
get_meeting_agenda

Retreive agenda for a specified meeting
get_parlperiod_presidency

Get list of presidency in a given parliamentary period
get_parlsessions

Get Parliamentary Sessions
get_mp_bio

Extract biography of specific MPs
get_mp

Extract information on specific MPs
get_session_decisions

Retrieve all decisions for a specified session
get_question

Parliamentary question
get_publication

Retrieve a specific publication
get_session_hearings

Retrieve hearings in specified session
get_session_meetings

Retrieve all meetings for a specified parliamentary session
get_written_hearing_input

Retrieve written input for a specified hearing
get_question_hour

Retrieve question hour details for a specified meeting
parl_periods

Parliamentary periods
get_result_vote

Retrieve vote results on MP level for a specified vote
get_vote

Retreive votes for a specific case
get_session_delegations

Parliamentary delegations in specified session
get_topics

Get list of topics and sub-topics for the Norwegian parliament
interp0203

Interpellations from the 2002-2003
mps4549

Members of parliament from the 1945-1949
get_session_parties

Parliamentary parties in specified session
get_session_mp_speech_activity

Retrieve all speech activity from one MP for a given session
get_session_cases

Cases in specified session
get_session_committees

Parliamentary committees in specified session
get_session_publications

Retrieve publications of a type in a parliamentary session
get_session_questions

Parliamentary questions in a session
vote_result

Roll call vote results for vote ids 15404, 15405, and 15406
read_obt

Read Oslo-Bergen-Tagger processed files into R
st_party_colors

Color palette for parties in the Storting
parl_sessions

Parliamentary sessions
vote

Meta data on votes of case id 78686
get_hearing_input

Retrieve the hearing input for a specified hearing
get_hearing_program

Retrieve the hearing program for a specified hearing
covid_relief_result

Vote id 85196 results
get_all_committees

Parliamentary committees over all sessions
get_proceedings

All parliamentary proceedings
get_proposal_votes

Retreive all votes for a specified vote proposal
get_counties

Get list of electoral districts
get_decision_votes

Retreive vote decision for a specified vote
get_parlperiod_mps

Get list of MPs in a given parliamentary period
covid_relief

Vote id 85196
cases

Storting cases in the 2019-2020 session
get_parlperiods

Get Parliamentary Periods
get_all_parties

All parliamentary parties
get_case

Retreive a parliamentary case