Title: | Access Data from the Norwegian Parliament API |
---|---|
Description: | Functions for retrieving general and specific data from the Norwegian Parliament, through the Norwegian Parliament API at <https://data.stortinget.no>. |
Authors: | Martin Søyland [aut, cre] |
Maintainer: | Martin Søyland <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3.2 |
Built: | 2024-11-15 09:22:40 UTC |
Source: | https://github.com/martigso/stortingscrape |
A dataset containing all cases of the 2019-2020 parliamentary session in Stortinget
cases
cases
A list with four elements
main data on the MP
named list by case id
named list by case id
named list by case id
https://data.stortinget.no/eksport/saker?sesjonid=2019-2020
A dataset containing all vote information on case id 85196
covid_relief
covid_relief
A data frame with 22 columns and 71 rows
Date of data retrieval
Data version from the API
Case id up for vote
Whether vote is an alternative vote
Number of votes for
Number of MPs absent
Number of votes against
Order of treated votes
Case number on the agenda of the meeting
Logical indication of whether the vote is related to the case as a whole
Vote comment
Number on the meeting map
Logical indication of whether vote was recorded as roll call or not
Id of president holding president chair at the time of voting
Party of the sitting president
Logical indication of whether the proposal voted on was adopted
Id of vote
Voting method
Result type (enstemmig_vedtatt = unanimously adopted)
See vote_result_type
Description of the proposal voted upon
Date and time of vote
https://data.stortinget.no/eksport/voteringer?sakid=85196
A dataset containing vote matrix on vote id 17689
covid_relief_result
covid_relief_result
A data frame with 8 columns and 169 rows
Date of data retrieval
Data version from the API
Id of vote
MP id
Party id
Vote: for, mot (against), ikke_tilstede (absent)
Id of the MP originally holding the seat, if the substitute is
Id of the MP originally holding the seat
https://data.stortinget.no/eksport/voteringsresultat?voteringid=17689
Imports data on all committee names and ids over all sessions in the data.stortinget.no API.
get_all_committees()
get_all_committees()
A data frame of committees, with the variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Id of the committee |
name | Name of the committee |
sessionid | Id of session (empty) |
## Not run: coms <- get_all_committees() head(coms) ## End(Not run)
## Not run: coms <- get_all_committees() head(coms) ## End(Not run)
A function for retrieving all Norwegian parliamentary parties in the data.stortinget.no API.
get_all_parties()
get_all_parties()
A data.frame of all parties, with the variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Id of the party |
name | Name of the party |
represented_party | Whether the party is represented at the time of download |
sessionid | Id of session (empty) |
period_id | Id of parliamentary period (empty) |
## Not run: parties <- get_all_parties() head(parties) ## End(Not run)
## Not run: parties <- get_all_parties() head(parties) ## End(Not run)
A function for retrieving single parliamentary case by id.
get_case(caseid = NA, good_manners = 0)
get_case(caseid = NA, good_manners = 0)
caseid |
Character string indicating the id of the case to request |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A list with seven data frame elements:
$root (main data on the case)
response_date | Date of data retrieval |
version | Data version from the API |
document_group | Case document group type |
finalized | Whether the case finalized |
reference | Relevant publication references |
id | Case id |
req_text | Recommendation (proposal) text |
committee_id | Id of committee handling the case |
title_short | Case short title |
decision_short | Case decision_short |
parenthesis_text | Case parenthesis text |
case_number | Case number |
session_id | Session id |
proceedings_id | Type of proceeding id |
proceedings_name | Type of proceeding name |
status | Status for case |
title | Case title (long) |
type | Case type |
decision_text | Decision text |
$topic (the topics related to the case)
is_main_topic | Is this (row) the main topic? |
main_topic_id | Id for main topic |
id | Topic id |
navn | Topic name |
$publication_references (references for publications on the case)
export_id | Id for export of publication (used in ?get_publication) |
link_text | Publication title |
link_url | URL to publication |
type | Publication type |
subtype | Publication subtype (chamber) |
$proposers (MPs behind case proposal, when relevant)
mp_id | MPs id |
party_id | Party id of MPs |
sub_mp | Whether MPs are substitutes |
$proceeding_steps (case proceeding steps)
step_name | Name of steps |
step_number | Step order for case |
outdated | Whether the step type is outdated |
$spokespersons (all MPs that are spokespersons for the case)
mp_id | MPs id |
party_id | Party id of MPs |
sub_mp | Whether MPs are substitutes |
$keywords (all keywords associated with the case)
keyword | Keywords for the case |
## Not run: # Get one case case <- get_case("30233") case # Get multiple cases cases <- lapply(c("30233", "30362", "30234", "30236"), get_case, good_manners = 2) cases_root <- lapply(cases, function(x) x$root) cases_root <- do.call(rbind, cases_root) cases_root cases_keywords <- lapply(1:nrow(cases_root), function(x){ tmp <- cases[[x]]$keywords tmp$case_id <- cases_root$id[x] return(tmp) }) cases_keywords <- do.call(rbind, cases_keywords) cases_keywords ## End(Not run)
## Not run: # Get one case case <- get_case("30233") case # Get multiple cases cases <- lapply(c("30233", "30362", "30234", "30236"), get_case, good_manners = 2) cases_root <- lapply(cases, function(x) x$root) cases_root <- do.call(rbind, cases_root) cases_root cases_keywords <- lapply(1:nrow(cases_root), function(x){ tmp <- cases[[x]]$keywords tmp$case_id <- cases_root$id[x] return(tmp) }) cases_keywords <- do.call(rbind, cases_keywords) cases_keywords ## End(Not run)
A function for retrieving current and/or historical electoral districts (counties) for the Norwegian parliament.
get_counties(historical = FALSE)
get_counties(historical = FALSE)
historical |
Logical. Whether or not to include historical counties. |
A data frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
historical_county | Whether the county is historical (no longer exists) |
id | Id of the county |
name | Name of the county |
## Not run: # Request one MP by id get_counties() # With historical counties get_counties(historical = TRUE) ## End(Not run)
## Not run: # Request one MP by id get_counties() # With historical counties get_counties(historical = TRUE) ## End(Not run)
A function for retrieving vote decisions from a specific vote. Vote data are only available from the 2011-2012 session
get_decision_votes(voteid = NA, good_manners = 0)
get_decision_votes(voteid = NA, good_manners = 0)
voteid |
Character string indicating the id of the vote to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
vote_id | Id of the vote |
decision_code | General code for decision |
decision_comment | Comments for the decision |
decision_number | Decision number |
decision_reference | Reference for the decision |
decision_text | Full text of the decision |
get_session_decisions get_proposal_votes get_vote get_result_vote
## Not run: decision <- get_decision_votes(123) decision ## End(Not run)
## Not run: decision <- get_decision_votes(123) decision ## End(Not run)
A function for retrieving the hearing input for a specified hearing.
get_hearing_input(hearingid = NA, good_manners = 0)
get_hearing_input(hearingid = NA, good_manners = 0)
hearingid |
Character string indicating the id of the hearing to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
hearing_id | Id of the hearing |
hearing_type | Type of hearing |
committee_id | Id of committee responsible for the hearing |
hearing_input_date | Date of receiving input |
hearing_input_id | Hearing input id |
hearing_input_organization | Organization giving input |
hearing_input_text | Full text of the hearing input |
hearing_input_title | Title of the hearing input |
get_session_hearings get_hearing_program get_written_hearing_input
## Not run: get_hearing_input(hearingid = 10004166) ## End(Not run)
## Not run: get_hearing_input(hearingid = 10004166) ## End(Not run)
A function for retrieving the hearing program for a specified hearing. The earlier periods (around 2005 and back) are less rich with data on some variables
get_hearing_program(hearingid = NA, good_manners = 0)
get_hearing_program(hearingid = NA, good_manners = 0)
hearingid |
Character string indicating the id of the hearing to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
hearing_id | Id of the hearing |
hearing_type | Type of hearing |
committee_id | Id of committee responsible for the hearing |
hearing_program_date | Date hearing program |
hearing_program_footnote | Footnote for hearing program |
order_number | Order number for the hearing program element |
text | Description of the hearing participant |
time_indication | Time stamp for participant hearing input |
date | Date of participant input in hearing |
get_session_hearings get_hearing_input get_written_hearing_input
## Not run: s0910 <- get_session_hearings("2009-2010") hearing <- get_hearing_program(s0910$hearing$hearing_id[1]) head(hearing) ## End(Not run)
## Not run: s0910 <- get_session_hearings("2009-2010") hearing <- get_hearing_program(s0910$hearing$hearing_id[1]) head(hearing) ## End(Not run)
A function for retrieving the agenda for a specific meeting.
get_meeting_agenda(meetingid = NA, good_manners = 0)
get_meeting_agenda(meetingid = NA, good_manners = 0)
meetingid |
Character string indicating the id of the meeting to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
agenda_number | The agenda number for the session |
meeting_date | Date of the meeting |
meeting_id | Meeting id |
meeting_place | Where the meeting was held |
agenda_case_reference | Reference for the case on the agenda |
agenda_case_number | Case number |
agenda_case_text | Case description |
agenda_case_type | Case type |
footnote | Footnote for the case |
proposition_id | If relevant, belonging proposition id |
committee_id | If relevant, id of the responsible committee |
loose_proposals | Whether there are loose proposals to the case |
case_id | Id of the case |
question_hour_type | If relevant, type of question hour |
question_id | If relevant, question id |
get_session_meetings get_case get_question get_question_hour
## Not run: meetings0910 <- get_session_meetings("2009-2010") meeting_agenda <- get_meeting_agenda(meetings0910$meeting_id[161]) meeting_agenda ## End(Not run)
## Not run: meetings0910 <- get_session_meetings("2009-2010") meeting_agenda <- get_meeting_agenda(meetings0910$meeting_id[161]) meeting_agenda ## End(Not run)
A function for retrieving information on Norwegian MPs from the parliament API
get_mp(mpid = NA, good_manners = 0)
get_mp(mpid = NA, good_manners = 0)
mpid |
Character string indicating the id of the MP to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
death | MP date of death, if applicable |
last_name | MP last name |
birth | MP date of birth |
first_name | MP first name |
id | MP id |
gender | MP gender |
get_mp_bio get_parlperiod_mps get_mp_pic get_session_mp_speech_activity
## Not run: # Request one MP by id get_mp("AAMH") # Request several MPs by id ids <- c("AAMH", "AMSK", "MAAA") mps <- lapply(ids, get_mp, good_manners = 2) mps <- do.call(rbind, mps) ## End(Not run)
## Not run: # Request one MP by id get_mp("AAMH") # Request several MPs by id ids <- c("AAMH", "AMSK", "MAAA") mps <- lapply(ids, get_mp, good_manners = 2) mps <- do.call(rbind, mps) ## End(Not run)
A function for retrieving biography of Norwegian MPs from the parliament API
get_mp_bio(mpid = NA, good_manners = 0)
get_mp_bio(mpid = NA, good_manners = 0)
mpid |
Character string indicating the id of the MP to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A list with ten data frames:
$root (main data on the MP)
response_date | Date of data retrieval |
version | Data version from the API |
id | Id of the MP |
$literature (all literature the MP contributed to)
year | Year of entry publication |
description | Description of the publication |
last_name | MP's last name |
more_years | Not described in the API |
publisher | Publisher |
first_name | First name of the MP |
place | Place of publication |
title | Title of the publication |
type | MP's role in publication (author etc) |
$leave_of_absence (times the MP was on leave)
from_date | Start date of leave |
reason | Reason for leave |
to_date | End of leave |
type | Type of leave |
sub_last_name | Substitute MP last name (id not recorded) |
sub_first_name | Substitute MP first name |
$personalia (the MP's personalia)
seniority_aar | Number of years in parliament |
seniority_dager | Number of extra days (addition to years) |
county_of_birth | Birth county of the MP |
municipality_of_birth | Birth municipality of the MP |
eulogy_date | Eulogy date of the MP, when applicable |
$father (the MP's father personalia)
death_year | Father's year of death |
last_name | Father's last name |
birth_year | Father's year of birth |
first_name | Father's first name |
profession | Father's profession |
$mother (the MP's mother personalia)
death_year | Mother's year of death |
last_name | Mother's last name |
birth_year | Mother's year of birth |
first_name | Mother's first name |
profession | Mother's profession |
$parl_periods (parliamentary periods the MP has held a seat)
from_date | Date MP held seat from |
county | County the MP represented |
party_id | Party id for the MP's party |
rep_number | Representative number (within the whol parliament) |
parl_period_id | Id of the parliamentary period |
to_date | Date MP held a seat to |
type | Type of representation |
$parl_positions (parliamentary positions held by the MP)
from_year | Year MP held position from |
from_date | Date MP held position from |
committee_id | Id of the position (in committee, cabinet, delegation, etc) |
committee_name | Position name |
committee_type | Position type |
sorting | Not described in the API |
parl_period_id | Parliamentary period the position was held (cabinet data missing) |
to_year | Year MP held position to |
to_date | Date MP held position to |
$vocation (vocation and education of the MP outside of parliament)
several_periods_text | Text description if the vocation was held for several periods |
from_year | Year MP held vocation from |
from_year_unknown | Logical indication for whether the start year is unknown |
note | Note for vocation |
name | Name of vocation |
to_year | Year MP held vocation to |
to_year_unknown | Logical indication for whether the end year is unknown |
type | Vocation type (10 = education, 20 = work) |
$other_positions (other positions held outside parliament)
several_periods_text | Text description if the vocation was held for several periods (removed from API) |
from_year | Year MP held vocation from |
from_year_sorting | Not described in API (removed from API) |
from_year_unknown | Logical indication for whether the start year is unknown |
max_to_year | The last possible time the MP held the position (removed from API) |
note | Note for position |
min_to_year | The earliest possible time the MP held the position (removed from API) |
level | Not described in API |
organization | Organization holding the position |
place | Place of the position |
to_year | Year MP held position to |
to_year_unknown | Logical indication for whether the end year is unknown |
type | Position type |
position | Position name/description |
get_mp get_parlperiod_mps get_mp_pic get_session_mp_speech_activity
## Not run: # Request one MP by id get_mp_bio("AAMH") ## End(Not run)
## Not run: # Request one MP by id get_mp_bio("AAMH") ## End(Not run)
A function for retrieving Norwegian MP pictures by id.
get_mp_pic(mpid = NA, size = "middels", destfile = NA, show_plot = FALSE, good_manners = 0)
get_mp_pic(mpid = NA, size = "middels", destfile = NA, show_plot = FALSE, good_manners = 0)
mpid |
Character string indicating the id of the MP to retrieve. |
size |
Character string size of the picture. Accepts values "lite" (small), "middels" (medium – default), and "stort" (big). |
destfile |
Character string specifying where to save the picture |
show_plot |
Logical. FALSE (default) if no plot should be produced and TRUE if plot should be produced. Requires the "imager" package. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
Picture of the requested MP in the preferred size.
get_mp get_parlperiod_mps get_mp_bio
## Not run: # Request one MP by id get_mp_pic(mpid = "AAMH", destfile = "~/Pictures/AAMH.jpeg", show_plot = TRUE, size = "stort") # With good manners for multiple calls lapply(c("AAMH", "CIH", "TKF"), function(x){ get_mp_pic(mpid = x, destfile = paste0("~/Pictures/", x), show_plot = TRUE, size = "stort", good_manners = 2) }) ## End(Not run)
## Not run: # Request one MP by id get_mp_pic(mpid = "AAMH", destfile = "~/Pictures/AAMH.jpeg", show_plot = TRUE, size = "stort") # With good manners for multiple calls lapply(c("AAMH", "CIH", "TKF"), function(x){ get_mp_pic(mpid = x, destfile = paste0("~/Pictures/", x), show_plot = TRUE, size = "stort", good_manners = 2) }) ## End(Not run)
A function for retrieving Norwegian MPs for a given parliamentary period from the parliament API
get_parlperiod_mps(periodid = NA, substitute = FALSE, good_manners = 0)
get_parlperiod_mps(periodid = NA, substitute = FALSE, good_manners = 0)
periodid |
Character string indicating the id of the parliamentary period to retrieve. |
substitute |
Logical. Whether or not to include substitute MPs. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
death | Date of death |
lastname | MP last name |
birth | Date of birth |
firstname | MP first name |
mp_id | MP id |
gender | MP gender |
county_id | Id of county MP represented |
party_id | Id of party MP represented |
substitute_mp | Logical for whether MP is a substitute |
period_id | Id of period represented in |
get_mp_bio get_mp get_mp_pic get_session_mp_speech_activity
## Not run: # Request one MP by id get_parlperiod_mps("2005-2009") # Request MPs from several periods by id ids <- c("1961-65", "1997-01", "2009-2013") mps <- lapply(ids, get_parlperiod_mps, good_manners = 2) mps <- do.call(rbind, mps) ## End(Not run)
## Not run: # Request one MP by id get_parlperiod_mps("2005-2009") # Request MPs from several periods by id ids <- c("1961-65", "1997-01", "2009-2013") mps <- lapply(ids, get_parlperiod_mps, good_manners = 2) mps <- do.call(rbind, mps) ## End(Not run)
A function for retrieving the presidency for a given parliamentary period from the parliament API.
get_parlperiod_presidency(periodid = NA, good_manners = 0)
get_parlperiod_presidency(periodid = NA, good_manners = 0)
periodid |
Character string indicating the id of the parliamentary period to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
last_name | Last name of presidency member |
first_name | First name of presidency member |
from_date | Presidency member from date |
party_id | Party affiliation of presidency member |
person_id | Id of the presidency member |
to_date | Presidency member to date |
position | Presidency position |
## Not run: # Request one MP by id get_parlperiod_presidency("2005-2009") ## End(Not run)
## Not run: # Request one MP by id get_parlperiod_presidency("2005-2009") ## End(Not run)
A function for retrieving dates of the parliamentary periods after WWII
get_parlperiods()
get_parlperiods()
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
from | Date session started |
id | Id of for session (used for other functions) |
to | Date session ended |
years | From year to year in full format |
## Not run: parlper <- get_parlperiods() parlper ## End(Not run)
## Not run: parlper <- get_parlperiods() parlper ## End(Not run)
A function for retrieving dates of the parliamentary sessions after WWII
get_parlsessions()
get_parlsessions()
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
from | Date session started |
id | Id of for session (used for other functions) |
to | Date session ended |
years | From year to year in full format |
## Not run: parlses <- get_parlsessions() parlses ## End(Not run)
## Not run: parlses <- get_parlsessions() parlses ## End(Not run)
A function for retrieving all proceedings in Stortinget, both current and historical.
get_proceedings()
get_proceedings()
A list with three dataframes:
$root (only download meta data)
response_date | Date of data retrieval |
version | Data version from the API |
$proceedings (description of main proceeding categories)
id | Id of proceeding |
name | Name of proceeding |
$poceedings_steps (description of proceeding steps within each main category)
id | Id of proceeding step |
name | Name of proceeding step |
step_number | Order of proceeding steps |
outdated | Whether the step is outdated |
main_id | Id for proceeding type the step belongs to |
## Not run: get_proceedings() ## End(Not run)
## Not run: get_proceedings() ## End(Not run)
A function for retrieving all votes from a specific vote proposal. Vote data are only available from the 2011-2012 session
get_proposal_votes(voteid = NA, good_manners = 0)
get_proposal_votes(voteid = NA, good_manners = 0)
voteid |
Character string indicating the id of the vote to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A list with two elements:
$proposal_vote (main data on the vote proposal)
response_date | Date of data retrieval |
version | Data version from the API |
vote_id | Id of the vote |
$proposal_by_parties${proposal_id} (what parties (id) stood behind proposal(s))
get_vote get_decision_votes get_result_vote
## Not run: prop <- get_proposal_votes(7523) prop for(i in 1:length(prop$proposal_by_parties)){ prop$proposal_vote$parties[i] <- paste0(prop$proposal_by_parties[[i]], collapse = ", ") } ## End(Not run)
## Not run: prop <- get_proposal_votes(7523) prop for(i in 1:length(prop$proposal_by_parties)){ prop$proposal_vote$parties[i] <- paste0(prop$proposal_by_parties[[i]], collapse = ", ") } ## End(Not run)
A function for retrieving a specific publication. Because these are formated very differently in the API, the returning object is in a raw html_document format, best manipulated with html packages such as rvest.
get_publication(publicationid = NA, good_manners = 0)
get_publication(publicationid = NA, good_manners = 0)
publicationid |
Character string indicating the id of the publication to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A raw html_document
get_question get_question_hour get_session_publications
## Not run: pub <- get_publication("refs-201819-03-06") (pub |> html_elements("replikk"))[1] |> html_text() ## End(Not run)
## Not run: pub <- get_publication("refs-201819-03-06") (pub |> html_elements("replikk"))[1] |> html_text() ## End(Not run)
A function for retrieving single parliamentary questions by id. For retrieving the whole debate over a question, the get_publication function has to be used
get_question(questionid = NA, good_manners = 0)
get_question(questionid = NA, good_manners = 0)
questionid |
Character string indicating the id of the session to request interpellations from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
justification | Justification for question |
answ_by_id | Id for answering minister |
answ_by_minister_id | Id for department of answering minister |
answ_by_minister_title | Title for department of answering minister |
answ_date | Date question was asked |
answ_on_belhalf_of | Id of minister answered on behalf of, when relevant |
answ_on_belhalf_of_minister_id | Id of department answered on behalf of, when relevant |
answ_on_belhalf_of_minister_title | Title of department answered on behalf of, when relevant |
agenda_number | Agenda number in meeting |
moved_to | Date moved to |
id | Question id |
correct_person_id | Not documented in API |
correct_person_minister_id | Not documented in API |
correct_person_minister_title | Not documented in API |
sendt_date | Date question was sent |
session_id | Session id |
question_text | Full question text |
question_from_id | Id of MP asking the question |
qustion_number | Question number |
qustion_to_id | Id of minister the question was asked to |
qustion_to_minister_id | Department id of minister the question was asked to |
qustion_to_minister_title | Department title of minister the question was asked to |
answer_text | Answer text (often empty) |
title | Question title |
type | Question type |
get_question_hour get_publication
## Not run: # An example of a possible workflow ## Retreive sessions sessions <- get_parlsessions() ## Retreive all interpellations for a particular session qsesh <- get_session_questions(sessions$id[9], q_type = "interpellasjoner") ## Retreve detailed information on all interpellations in that session library(pbmcapply) # for progress bar. never use paralell on scraping int1213 <- pbmclapply(qsesh$id, function(x){ get_question(x, good_manners = 2) }, mc.cores = 1) quest1213 <- do.call(rbind, int1213) ## End(Not run)
## Not run: # An example of a possible workflow ## Retreive sessions sessions <- get_parlsessions() ## Retreive all interpellations for a particular session qsesh <- get_session_questions(sessions$id[9], q_type = "interpellasjoner") ## Retreve detailed information on all interpellations in that session library(pbmcapply) # for progress bar. never use paralell on scraping int1213 <- pbmclapply(qsesh$id, function(x){ get_question(x, good_manners = 2) }, mc.cores = 1) quest1213 <- do.call(rbind, int1213) ## End(Not run)
A function for retrieving detailed overview of the question hour for a specific meeting
get_question_hour(meetingid = NA, good_manners = 0)
get_question_hour(meetingid = NA, good_manners = 0)
meetingid |
Character string indicating the id of the meeting to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A list with ten data frames:
$root (download meta data)
response_date | Date of data retrieval |
version | Data version from the API |
meetingid | The called meeting id |
$question_hour_ministers (id of ministers in parliament during question hour/time)
id | Id of ministers attending |
$question_time
question_justification | Justification for question |
answer_by_id | Id for answering minister |
answer_by_minister_id | Id for department of answering minister |
answer_by_minister_title | Title for department of answering minister |
answer_date | Date of receiving answer |
answer_on_behalf_of_id | Id of minister answered on behalf of, when relevant |
answer_on_behalf_of_minister_id | Id of department answered on behalf of, when relevant |
answer_on_behalf_of_minister_title | Title of department answered on behalf of, when relevant |
agenda_case_number | Case number on agenda |
date | Date question hour was held |
moved_to | Date moved to |
asked_by_other_id | Id for minister asking on behalf of another, when relevant |
question_id | Question id |
correct_person | Not documented in API |
correct_person_minister_id | Not documented in API |
correct_person_minister_title | Not documented in API |
sent_date | Date question was sent |
session_id | Session id |
question_text | Full question text |
question_from_id | Id of MP asking the question |
question_number | Question number |
question_to_id | Id of minister the question was asked to |
question_to_minister_id | Department id of minister the question was asked to |
question_to_minister_title | Department title of minister the question was asked to |
status | Question status |
answer | Answer text (often empty) |
title | Question title |
type | Question type |
$publication_reference
export_id | Export id for publication (see get_publication()) |
link_text | Description text for publication |
link_url | URL for publication |
type | Type of publication |
sub_type | Subtype for publication (location) |
get_question get_session_questions get_publication
## Not run: get_question_hour(10232) ## End(Not run)
## Not run: get_question_hour(10232) ## End(Not run)
A function for retrieving vote results from a specific vote on MP level. Vote data are only available from the 2011-2012 session. Needs some preprocessing for use with rollcall packages, such as ideal.
get_result_vote(voteid = NA, good_manners = 0)
get_result_vote(voteid = NA, good_manners = 0)
voteid |
Character string indicating the id of the vote to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
vote_id | Id of vote |
mp_id | MP id |
party_id | Party id |
vote | Vote: for, mot (against), ikke_tilstede (absent) |
permanent_sub_for | Id of the MP originally holding the seat, if the substitute is permanent |
sub_for | Id of the MP originally holding the seat |
get_decision_votes get_proposal_votes get_vote get_mp_bio
## Not run: v <- get_result_vote(12345) table(v$vote) p <- get_proposal_votes(12345) stringr::str_replace_all(p$proposal_vote$proposal_text, "\\<(.*)\\>|\\r\\n", "") |> stringr::str_trim() ## End(Not run)
## Not run: v <- get_result_vote(12345) table(v$vote) p <- get_proposal_votes(12345) stringr::str_replace_all(p$proposal_vote$proposal_text, "\\<(.*)\\>|\\r\\n", "") |> stringr::str_trim() ## End(Not run)
A function for retrieving all cases treated in a specified parliamentary session.
get_session_cases(sessionid = NA, good_manners = 0, cores = 1)
get_session_cases(sessionid = NA, good_manners = 0, cores = 1)
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
cores |
Integer. Number of cores (1 by default) to use in structuring the data. More than 1 will not work on windows |
A data.frame with the following variables:
$root (main data on the MP)
response_date | Date of data retrieval |
version | Data version from the API |
treated_session_id | Session the case was treated in |
document_group | Document group the case belongs to |
reference | Document reference |
id | Case id |
com_req_id | Committee recommendation id |
com_req_code | Committee recommendation code |
title_short | Short title of case |
case_filed_id | Id of filed case |
last_update_date | Date of last update on case |
status | Status of the case |
title | Full title of the case |
type | Type of case |
session_id | Session id of the case |
committee_id | Responsible committee id |
$topics (named list by case id)
is_main_topic | Logical indication whether the topic is the main topic |
main_topic_id | Id of the main topic for the case |
id | Topic id |
name | Topic name |
$proposers (named list by case id)
rep_id | Proposing MP id |
county_id | County id of proposing MP |
party_id | Party id of proposing MP |
rep_sub | Logical indicator for whether MP is a substitute |
$spokespersons (data frame by case id)
case_id | Case id |
rep_id | Spokesperson(s) MP id for the case |
county_id | County id of spokesperson MP |
party_id | Party id of spokesperson MP |
rep_sub | Logical indicator for whether MP is a substitute |
## Not run: s0506 <- get_session_cases("2005-2006") head(s0506) ## End(Not run)
## Not run: s0506 <- get_session_cases("2005-2006") head(s0506) ## End(Not run)
A function for retrieving Norwegian parliamentary committees for a specified parliamentary session
get_session_committees(sessionid = NA, good_manners = 0)
get_session_committees(sessionid = NA, good_manners = 0)
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Committee id |
name | Committee name |
session_id | Session id |
get_all_committees get_mp_bio get_mp
## Not run: coms <- get_session_committees("2001-2002") coms ## End(Not run)
## Not run: coms <- get_session_committees("2001-2002") coms ## End(Not run)
A function for retrieving all decisions from a specific parliamentary session.
get_session_decisions(sessionid = NA, good_manners = 0)
get_session_decisions(sessionid = NA, good_manners = 0)
sessionid |
Character string indicating the id of the session to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
decision_id | Decision id |
case_id | Case id |
case_link_url | URL for case to front end web page |
decision_date | Decision date |
decision_link_url | URL for decision to front end web page |
decision_number | Decision number within session |
decision_text | Decision text |
decision_title | Decision title |
decision_type_id | Decision type id |
decision_type_name | Decision type name |
## Not run: desci <- get_session_decisions("2004-2005") head(desci) ## End(Not run)
## Not run: desci <- get_session_decisions("2004-2005") head(desci) ## End(Not run)
A function for retrieving delegations for a specified parliamentary session.
get_session_delegations(sessionid = NA, good_manners = 0)
get_session_delegations(sessionid = NA, good_manners = 0)
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Delegation id |
name | Name of delegation |
session_id | Session id |
get_session_committees get_all_committees
## Not run: deleg <- get_session_delegations("2015-2016") deleg ## End(Not run)
## Not run: deleg <- get_session_delegations("2015-2016") deleg ## End(Not run)
A function for retrieving all hearings in a specified parliamentary session.
get_session_hearings(sessionid = NA, good_manners = 0, cores = 1)
get_session_hearings(sessionid = NA, good_manners = 0, cores = 1)
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
cores |
Integer... |
A list with four elements:
$root (hearing meta data)
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
$hearing (main data on the hearing)
deadline_date | Deadline date for hearing |
status | Data version from the API |
hearing_id | Hearing id |
input_deadline | Deadline date for input |
written | Logical indication of whether the input was written |
application_deadline | Deadline date for application to hearing |
start_date | Start date for hearing |
status_pub | Publication status for hearing |
status_info_text | Status information text |
type | Type of hearing |
committee_id | Committee id for committee responsible for hearing |
$hearing_case_info (named list by hearing id with information on the case(s) belonging to the hearing)
hearing_id | Hearing id |
case_reference | Text reference for case |
case_id | Case id |
case_short_title | Short title for case |
case_publication | URL for front end web-page publication |
case_title | Full title for case |
$hearing_date (named list by hearing id with date(s) the hearing was held)
hearing_id | Hearing id |
date | Date of hearing |
place | Where the hearing was held |
get_hearing_input get_hearing_program get_written_hearing_input
## Not run: hear <- get_session_hearings("2010-2011") head(hear$hearing) ## End(Not run)
## Not run: hear <- get_session_hearings("2010-2011") head(hear$hearing) ## End(Not run)
A function for retrieving meetings from a specific parliamentary session
get_session_meetings(sessionid = NA, good_manners = 0)
get_session_meetings(sessionid = NA, good_manners = 0)
sessionid |
Character string indicating the id of the session to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
agenda_number | Agenda number within the session |
footnote | Footnotes for the meeting |
meeting_id | Meeting id |
no_meeting_text | Description of why there was no meeting, if relevant |
evening_meeting | Whether the meeting was an evening meeting or not |
note | Note for the meeting |
meeting_date | Date the meeting took place |
meeting_order | Indicator for meeting order |
meeting_place | Where the meeting took place |
transcript_id | Id for transcript (usually empty) |
additional_agenda | Logical indicator for whether there was additional agenda to the meeting |
get_meeting_agenda get_question_hour
## Not run: meet <- get_session_meetings("2013-2014") head(meet) ## End(Not run)
## Not run: meet <- get_session_meetings("2013-2014") head(meet) ## End(Not run)
A function for retrieving all speech activity from an MP during a specific parliamentary session. Only available from the 2011-2012 session and onwards.
get_session_mp_speech_activity(sessionid = NA, mp_id = NA, good_manners = 0)
get_session_mp_speech_activity(sessionid = NA, mp_id = NA, good_manners = 0)
sessionid |
Character string indicating the session to retrieve speeches from. |
mp_id |
Character string for the MP to retreive all speeches of in a given session. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
agenda_case_number | Number indicating the agenda number for the case |
meeting_id | Meeting id |
speech_start_time | Start time of speech |
speech_type | Type of speech |
speech_length_secs | Lenght of speech in seconds |
get_mp get_mp_bio get_publication
## Not run: activ <- get_session_mp_speech_activity("2012-2013", "ALYS") head(activ) ## End(Not run)
## Not run: activ <- get_session_mp_speech_activity("2012-2013", "ALYS") head(activ) ## End(Not run)
A function for retrieving Norwegian parliamentary parties for a specified parliamentary session
get_session_parties(sessionid = NA, good_manners = 0)
get_session_parties(sessionid = NA, good_manners = 0)
sessionid |
Character string indicating the id of the parliamentary session to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
id | Party id |
name | Party name |
represented_party | Logical indication of whether party was represented |
session_id | Session id |
period_id | Parliamentary period id |
## Not run: parties <- get_session_parties("2003-2004") parties ## End(Not run)
## Not run: parties <- get_session_parties("2003-2004") parties ## End(Not run)
A function for retrieving one of several publication types within a parliamentary session.
get_session_publications(sessionid = NA, type = "referat", good_manners = 0)
get_session_publications(sessionid = NA, type = "referat", good_manners = 0)
sessionid |
Character string indicating the id of the hearing to retrieve. |
type |
Character specifying type of publication to download. Available types are "referat" (minutes), "innstilling" (proposition), "innberetning" (report), "lovvedtak" (law decision), "lovanmerkning" (law note), "dok8" (MP proposal) "dok12" (Constitutional proposal), and "dokumentserie" (document series). Defaults to "referat". |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
session_id | Session id |
publication_date | Date of publication |
publication_id | Id of publication |
publication_format | Publication format (XML) |
publication_available_date | When the publication was made available |
publication_title | Publication title |
publication_type | Publication type |
## Not run: pub <- get_session_publications("1998-99") head(pub) ## End(Not run)
## Not run: pub <- get_session_publications("1998-99") head(pub) ## End(Not run)
A function for retrieving all questions within a parliamentary session.
get_session_questions(sessionid = NA, q_type = NA, status = NA, good_manners = 0)
get_session_questions(sessionid = NA, q_type = NA, status = NA, good_manners = 0)
sessionid |
Character string indicating the id of the session to request interpellations from |
q_type |
Character string indicating type of question to retrieve. Options are "interpellasjoner" (interpellations), "sporretimesporsmal" (oral questions), or "skriftligesporsmal" (written questions). |
status |
Character string question status extraction. Possible values are NA (extract all questions), "til_behandling" (pending questions), "trukket" (withdrawn questions), "bortfalt" (lapsed questions), or "alle" (all questions) |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
answ_by_id | Id of minister answering question |
answ_by_minister_id | Department id of answering minister |
answ_by_minister_title | Department title of answering minister |
answ_date | Date answer was given |
answ_on_belhalf_of | Answer given on behalf of |
answ_on_belhalf_of_minister_id | Department id of minister given answer on behalf of |
answ_on_belhalf_of_minister_title | Department title of minister given answer on behalf of |
topic_ids | Id of relevant topics for question |
moved_to | Question moved to |
asked_by_other_id | MP id, if question was not asked by the questioning MP |
id | Question id |
correct_person | Not documented in API |
correct_person_minister_id | Not documented in API |
correct_person_minister_title | Not documented in API |
sendt_date | Date the question was sent |
session_id | Session id |
question_from_id | Question from MP id |
question_number | Question number within session |
question_to_id | Question directed to minister id |
question_to_minister_id | Question directed to minister department id |
question_to_minister_title | Question directed to minister department title |
status | Question status |
title | Question title |
type | Question type |
get_question_hour get_question
## Not run: interp <- get_session_questions(sessionid = "2013-2014", q_type = "interpellasjoner", status = "trukket") interp ## End(Not run)
## Not run: interp <- get_session_questions(sessionid = "2013-2014", q_type = "interpellasjoner", status = "trukket") interp ## End(Not run)
A function for retrieving topic keys used to label various data from the Norwegian parliament.
get_topics(keep_sub_topics = TRUE)
get_topics(keep_sub_topics = TRUE)
keep_sub_topics |
Logical. Whether to keep sub-topics (default) for all main topics or not. |
A list with two elements:
$topics (All topics)
response_date | Date of data retrieval |
version | Data version from the API |
is_main_topic | Logical indicator for whether the topic is a main topic |
main_topic_id | Id of main topic |
id | Id of topic |
name | Name of topic |
$main_topics (exclusively main topics, if keep_sub_topics = TRUE)
response_date | Date of data retrieval |
version | Data version from the API |
is_main_topic | Logical indicator for whether the topic is a main topic |
main_topic_id | Id of main topic |
id | Id of topic |
name | Name of topic |
# Request the data tops <- get_topics() # Look at the first main topic tops$main_topics[1, ] # Extract all sub-topics for the first main topic tops$topics[which(tops$topics$main_topic_id == 5), ]
# Request the data tops <- get_topics() # Look at the first main topic tops$main_topics[1, ] # Extract all sub-topics for the first main topic tops$topics[which(tops$topics$main_topic_id == 5), ]
A function for retrieving all votes from a case. Vote data are only available from the 2011-2012 session
get_vote(caseid = NA, good_manners = 0)
get_vote(caseid = NA, good_manners = 0)
caseid |
Character string indicating the id of the case to request all votes from |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame with the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
case_id | Case id up for vote |
alternative_vote | Whether vote is an alternative vote |
n_for | Number of votes for |
n_absent | Number of MPs absent |
n_against | Number of votes against |
treatment_order | Order of treated votes |
agenda_case_number | Case number on the agenda of the meeting |
free_vote | Logical indication of whether the vote is related to the case as a whole |
comment | Vote comment |
meeting_map_number | Number on the meeting map |
personal_vote | Logical indication of whether vote was recorded as roll call or not |
president_id | Id of president holding president chair at the time of voting |
president_party_id | Party of the sitting president |
adopted | Logical indication of whether the proposal voted on was adopted |
vote_id | Id of vote |
vote_method | Voting method |
vote_result_type | Result type (enstemmig_vedtatt = unanimously adopted) |
vote_result_type_text | See vote_result_type |
vote_topic | Description of the proposal voted upon |
vote_datetime | Date and time of vote |
get_decision_votes get_proposal_votes get_vote get_session_cases get_case
## Not run: get_vote(63033) ## End(Not run)
## Not run: get_vote(63033) ## End(Not run)
A function for retrieving written input for a specified hearing
get_written_hearing_input(hearingid = NA, good_manners = 0)
get_written_hearing_input(hearingid = NA, good_manners = 0)
hearingid |
Character string indicating the id of the hearing to retrieve. |
good_manners |
Integer. Seconds delay between calls when making multiple calls to the same function |
A data.frame the following variables:
response_date | Date of data retrieval |
version | Data version from the API |
hearing_id | Id of the hearing |
hearing_type | Type of hearing |
committee_id | Id of committee responsible for the hearing |
hearing_input_date | Date of receiving input |
hearing_input_id | Hearing input id |
hearing_input_organization | Organization giving input |
hearing_input_text | Full text of the hearing input |
hearing_input_title | Title of the hearing input |
get_hearing_input get_hearing_program get_session_hearings
## Not run: get_written_hearing_input(hearingid = 10004243) ## End(Not run)
## Not run: get_written_hearing_input(hearingid = 10004243) ## End(Not run)
A dataset containing all interpellations in the 2002-2003 parliamentary session in Stortinget
interp0203
interp0203
A data frame with 26 columns and 22 rows
Date of data retrieval
Data version from the API
Id of minister answering question
Department id of answering minister
Department title of answering minister
Date answer was given
Answer given on behalf of
Department id of minister given answer on behalf of
Department title of minister given answer on behalf of
Id of relevant topics for question
Question moved to
MP id, if question was not asked by the questioning MP
Question id
Not documented in API
Not documented in API
Not documented in API
Date the question was sent
Session id
Question from MP id
Question number within session
Question directed to minister id
Question directed to minister department id
Question directed to minister department title
Question type
Question title
Question status
https://data.stortinget.no/eksport/interpellasjoner?sesjonid=2002-2003
A dataset containing all MPs during the 1945-1949 parliamentary period in Stortinget
mps4549
mps4549
A data frame with 12 columns and 150 rows
Date of data retrieval
Data version from the API
Date of death
MP last name
Date of birth
MP first name
MP id
MP gender
Id of county MP represented
Id of party MP represented
Logical for whether MP is a substitute
Id of period represented in
https://data.stortinget.no/eksport/representanter?stortingsperiodeid=1945-49
A dataset containing all parliamentary periods in Stortinget
parl_periods
parl_periods
A data frame with 12 columns and 150 rows
Date of data retrieval
Data version from the API
Date session started
Id of for session (used for other functions)
Date session ended
From year to year in full format
https://data.stortinget.no/eksport/stortingsperioder
A dataset containing all parliamentary sessions in Stortinget
parl_sessions
parl_sessions
A data frame with 6 columns and 36 rows
Date of data retrieval
Data version from the API
Date session started
Id of for session (used for other functions)
Date session ended
From year to year in full format
https://data.stortinget.no/eksport/sesjoner
A function reading OBT-tagged files
read_obt(file = NA)
read_obt(file = NA)
file |
character. Path to OBT-tagged file |
A data frame with the following variables:
sentence | Sentence number |
index | Token number in sentence |
token | Raw token, as read by OBT originally |
lwr | Lowercase raw token |
lemma | Lemmatized token |
pos | Part of Speech |
morph | Morphological tags |
## Not run: sample_text <- read_obt("./inst/extdata/obt_sample.txt") head(sample_text) ## End(Not run)
## Not run: sample_text <- read_obt("./inst/extdata/obt_sample.txt") head(sample_text) ## End(Not run)
A color palette for all (current) parties in the Storting
st_party_colors
st_party_colors
A vector of party abbreviations and official hex colors
https://www.frp.no/files/Grafiske-retningslinjer/FrP-Profilmanual-2023.pdf
https://profil.senterpartiet.no/point/no/senterpartietbc/component/default/24406
See list of links above; there are several color alternatives for most parties.
## Not run: barplot(table(get_parlperiod_mps(parl_periods$id[1])$party_id), col = st_party_colors) ## End(Not run)
## Not run: barplot(table(get_parlperiod_mps(parl_periods$id[1])$party_id), col = st_party_colors) ## End(Not run)
A dataset containing vote infomation on case id 78686 in Stortinget
vote
vote
A list with three elements (votes)
Date of data retrieval
Data version from the API
Case id up for vote
Whether vote is an alternative vote
Number of votes for
Number of MPs absent
Number of votes against
Order of treated votes
Case number on the agenda of the meeting
Logical indication of whether the vote is related to the case as a whole
Vote comment
Number on the meeting map
Logical indication of whether vote was recorded as roll call or not
Id of president holding president chair at the time of voting
Party of the sitting president
Logical indication of whether the proposal voted on was adopted
Id of vote
Voting method
Result type (enstemmig_vedtatt = unanimously adopted)
See vote_result_type
Description of the proposal voted upon
Date and time of vote
https://data.stortinget.no/eksport/voteringsresultat?voteringid=15404
A dataset containing all personal votes for votes 15404, 15405, and 15406 in Stortinget
vote_result
vote_result
A list with one vote per element
Date of data retrieval
Data version from the API
Id of vote
MP id
Party id
Vote: for, mot (against), ikke_tilstede (absent)
Id of the MP originally holding the seat, if the substitute is permanent
Id of the MP originally holding the seat
https://data.stortinget.no/eksport/voteringsresultat?voteringid=15404, https://data.stortinget.no/eksport/voteringsresultat?voteringid=15405, https://data.stortinget.no/eksport/voteringsresultat?voteringid=15406