| 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] (ORCID: <https://orcid.org/0000-0002-2463-8469>) |
| Maintainer: | Martin Søyland <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.5.0 |
| Built: | 2026-10-09 12:06:23 UTC |
| Source: | https://github.com/martigso/stortingscrape |
A dataset containing all cases of the 2019-2020 parliamentary session in Stortinget
casescases
A list with four elements
main data on the cases
named list by case id
named list by case id
named list by case id
The dataset was retrieved with an earlier version of the package; get_session_cases now returns
$spokespersons as a data frame.
https://data.stortinget.no/eksport/saker?sesjonid=2019-2020
A dataset containing all vote information on case id 85196
covid_reliefcovid_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 the vote matrix on vote id 17689
covid_relief_resultcovid_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 permanent
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, or a vector of strings, indicating the id of the case to request. With several ids, the result is a named list of the results below, keyed by case id. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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 (a list keyed by case id) cases <- get_case(c("30233", "30362", "30234", "30236"), good_manners = 2) cases_root <- do.call(rbind, lapply(cases, function(x) x$root)) cases_root cases_keywords <- lapply(names(cases), function(id){ data.frame(case_id = id, cases[[id]]$keywords) }) 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 (a list keyed by case id) cases <- get_case(c("30233", "30362", "30234", "30236"), good_manners = 2) cases_root <- do.call(rbind, lapply(cases, function(x) x$root)) cases_root cases_keywords <- lapply(names(cases), function(id){ data.frame(case_id = id, cases[[id]]$keywords) }) 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 current counties get_counties() # With historical counties get_counties(historical = TRUE) ## End(Not run)## Not run: # Request current counties 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, or a vector of strings, indicating the id of the vote to retrieve decisions from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the hearing to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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_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, or a vector of strings, indicating the id of the hearing to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the meeting to retrieve the agenda from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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 |
| legacy_question_id | Legacy question id, only used for matching with old data (pre 10.12.2024) |
| 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, or a vector of strings, indicating the id of the MP to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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 mps <- get_mp(c("AAMH", "AMSK", "MAAA"), good_manners = 2) ## End(Not run)## Not run: # Request one MP by id get_mp("AAMH") # Request several MPs by id mps <- get_mp(c("AAMH", "AMSK", "MAAA"), good_manners = 2) ## 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, or a vector of strings, indicating the id of the MP to retrieve. With several ids, the result is a named list of the results below, keyed by MP id. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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_years | Number of years in parliament |
| seniority_days | 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 whole 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)
| from_year | Year MP held vocation from |
| from_year_unknown | Logical indication for whether the start year is unknown |
| note | Note for position |
| 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, or a vector of strings, 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. With several ids, one destfile per id. |
show_plot |
Logical. FALSE (default) if no plot should be produced and TRUE if plot should be produced. Requires the "magick" package. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
No return value; called for its side effects (saves the picture to destfile and/or plots it).
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") # Several MPs, one file each, with good manners ids <- c("AAMH", "CIH", "TKF") get_mp_pic(mpid = ids, destfile = paste0("~/Pictures/", ids, ".jpeg"), 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") # Several MPs, one file each, with good manners ids <- c("AAMH", "CIH", "TKF") get_mp_pic(mpid = ids, destfile = paste0("~/Pictures/", ids, ".jpeg"), 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, or a vector of strings, indicating the id of the parliamentary period to retrieve. |
substitute |
Logical. Whether or not to include substitute MPs. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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 MPs from one period get_parlperiod_mps("2005-2009") # Request MPs from several periods mps <- get_parlperiod_mps(c("1961-65", "1997-2001", "2009-2013"), good_manners = 2) ## End(Not run)## Not run: # Request MPs from one period get_parlperiod_mps("2005-2009") # Request MPs from several periods mps <- get_parlperiod_mps(c("1961-65", "1997-2001", "2009-2013"), good_manners = 2) ## 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, or a vector of strings, indicating the id of the parliamentary period to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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 |
| period_id | Id of the parliamentary period |
## Not run: # Request the presidency for one period get_parlperiod_presidency("2005-2009") ## End(Not run)## Not run: # Request the presidency for one period 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 period started |
| id | Id of the period (used by other functions) |
| to | Date period 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 the session (used by 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 |
$proceedings_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, or a vector of strings, indicating the id of the vote to retrieve proposals from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
A list with two elements:
$proposal_vote (main data on the proposals, one row per proposal)
| response_date | Date of data retrieval |
| version | Data version from the API |
| vote_id | Id of the vote |
| proposal_designation | Designation of the proposal |
| proposal_designation_short | Short designation of the proposal |
| proposal_id | Id of the proposal |
| proposal_delivered_by_mp | Id of the MP delivering the proposal |
| proposal_on_behalf_of_text | Text on whose behalf the proposal is |
| proposal_sortingnumber | Sorting number of the proposal |
| proposal_text | Text of the proposal |
| proposal_type | Type of proposal |
$proposal_by_parties (a list named by proposal_id, each element a character vector of the ids
of the parties behind the proposal)
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 formatted very differently in the API,
the returning object is the raw XML document, best manipulated with node extraction functions
such as rvest::html_elements() or xml2::xml_find_all().
get_publication(publicationid = NA, good_manners = 0)get_publication(publicationid = NA, good_manners = 0)
publicationid |
Character string, or a vector of strings, indicating the id of the publication to retrieve |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
Note that element and attribute names are case sensitive. Publications from before the 2016-2017 session
use lowercase names (e.g. innlegg, sakid), while later publications use capitalized names
(e.g. Replikk, personID). For debate transcripts, get_speeches returns the speeches as a data frame.
A raw xml_document
get_speeches 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, or a vector of strings, indicating the id of the question to retrieve |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
A data.frame with the following variables:
| 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 the question was answered |
| answ_on_behalf_of | Id of minister answered on behalf of, when relevant |
| answ_on_behalf_of_minister_id | Id of department answered on behalf of, when relevant |
| answ_on_behalf_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 |
| legacy_id | Question legacy id (only use to match with data downloaded before 10.12.2024) |
| correct_person_id | 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 |
| response_date | Date of data retrieval |
| version | Data version from the API |
| question_from_id | Id of MP asking the question |
| question_from_county_id | Id of the county of the MP asking the question |
| question_from_party_id | Id of the party of the MP asking the question |
| question_from_deputy | Whether the MP asking the question is a substitute |
| 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 | Status of the question |
| answer_text | Answer text (often empty) |
| title | Question title |
| type | Question type |
| asked_by_other_id | ID of person that asked the question on behalf of question_from_id
|
get_question_hour get_publication get_meeting_agenda
## Not run: # An example of a possible workflow ## Retrieve all interpellations for a particular session qsesh <- get_session_questions("2012-2013", q_type = "interpellasjoner") ## Retrieve detailed information on all interpellations in that session int1213 <- get_question(qsesh$id, good_manners = 2) ## End(Not run)## Not run: # An example of a possible workflow ## Retrieve all interpellations for a particular session qsesh <- get_session_questions("2012-2013", q_type = "interpellasjoner") ## Retrieve detailed information on all interpellations in that session int1213 <- get_question(qsesh$id, good_manners = 2) ## 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, or a vector of strings, indicating the id of the meeting to retrieve the question hour from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
A list with four 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, or a vector of strings, indicating the id of the vote to retrieve results from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the parliamentary session to retrieve. With several ids, the result is a named list of the results below, keyed by session id. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
cores |
Integer. Number of cores (1 by default) to use in structuring the data. More than 1 will not work on Windows. |
A list with four elements:
$root (main data on the cases)
| 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$root) ## End(Not run)## Not run: s0506 <- get_session_cases("2005-2006") head(s0506$root) ## 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, or a vector of strings, indicating the id of the parliamentary session to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the session to retrieve decisions from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the parliamentary session to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the parliamentary session to retrieve. With several ids, the result is a named list of the results below, keyed by session id. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
cores |
Integer. Number of cores (1 by default) to use in structuring the data. More than 1 will not work on Windows. |
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 | Status of the hearing |
| 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 (the case(s) belonging to each hearing, by hearing id)
| 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 (the date(s) and place(s) each hearing was held, by hearing id)
| 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, or a vector of strings, indicating the id of the session to retrieve meetings from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, mpid = NA, good_manners = 0, mp_id = NULL)get_session_mp_speech_activity(sessionid = NA, mpid = NA, good_manners = 0, mp_id = NULL)
sessionid |
Character string, or a vector of strings, indicating the session to retrieve speeches from. |
mpid |
Character string, or a vector of strings, for the MP to retrieve all speeches of in a given session. With several sessions and/or MPs, all combinations are retrieved and bound together. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
mp_id |
Deprecated; use |
A data.frame with the following variables:
| response_date | Date of data retrieval |
| version | Data version from the API |
| session_id | Session id |
| mp_id | Id of the MP |
| 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 | Length 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, or a vector of strings, indicating the id of the parliamentary session to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the session to retrieve publications from. |
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 |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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, or a vector of strings, indicating the id of the session to retrieve questions from |
q_type |
Character string indicating type of question to retrieve (required). 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 |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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_behalf_of | Answer given on behalf of |
| answ_on_behalf_of_minister_id | Department id of minister given answer on behalf of |
| answ_on_behalf_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 |
| sent_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 all speeches in a debate transcript (publication type "referat"), one row per speech. Handles both the transcript format used up to the 2015-2016 session and the format used from the 2016-2017 session onward, returning the same variables for both. Plenary sittings, open hearings, and meetings in the European Committee are all published as transcripts.
get_speeches(publicationid = NA, good_manners = 0, link = TRUE)get_speeches(publicationid = NA, good_manners = 0, link = TRUE)
publicationid |
Character string, or a vector of strings, indicating the id of the transcript to retrieve.
Ids can be found with get_session_publications ( |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
link |
Logical. Whether to add person ids linked from the names of speakers and chairs
(see speaker_links). Defaults to |
Some speech elements in the transcripts hold more than one speaker (e.g. a question and an answer in
a hearing). These are split into one row per speaker; speech_order identifies the speech element
and speech_part the speaker within it.
The transcripts before about 2005 mostly do not say whether a speech is a main speech
("hovedinnlegg") or a reply ("replikk"); speech_type is then NA, except for the president's
remarks ("presinnlegg").
The meeting date is given both in the meeting heading (weekday, day, month, and, from 2007 onward,
year) and in the publication id, and both contain occasional errors. When they agree, that date is
used; when they disagree, the one whose weekday matches the weekday in the heading is used, and NA
if that does not settle it.
Speakers are only identified by the API (person_id) in transcripts from the 2016-2017 session onward,
and not for all speeches (e.g. not for the president or committee chair). Note that these ids are not
always correct: speeches are sometimes tagged with the id of another person than the one named in
speaker_raw. A numeric suffix that some of these ids carry (e.g. "ARK_775612110") is removed. The
raw speaker string is always kept in speaker_raw; speaker_title, speaker_name, speaker_party,
and speech_time are parsed from it.
With link = TRUE (the default), person ids linked from the names of the speakers and chairs are
added from the speaker_links dataset (linked_person_id, link_method, and chair_linked_id),
also for transcripts before 2016-2017. These links are made by the package, not given by the API
(person_id is kept as the API gives it), and they only cover the sessions in speaker_links; for
later sessions, the linked ids are NA.
The sitting chair (president or meeting leader) is tracked through the transcript: the chair named at
the start of each meeting, updated at the transcript's notes on changes of chair (e.g. "X hadde her
overtatt presidentplassen"). When a note about the chair cannot be read, the chair is set to NA
until the next recognized change. chair_id is only given for the chair named at the start of a
meeting, and only when the transcript includes it (a numeric suffix that some of these ids carry,
e.g. "OLET_62710109", is removed).
A data.frame with the following variables:
| response_date | Date and time of retrieval (the transcripts have no response date of their own) |
| publication_id | Id of the transcript |
| session_id | Id of the parliamentary session (see get_parlsessions), from meeting_date |
| meeting_order | Order of the meeting within the transcript (some transcripts hold several meetings) |
| meeting_id | Meeting id (see get_session_meetings), when given in the transcript |
| meeting_title | Raw meeting heading (e.g. "Møte torsdag den 13. februar 2014 kl. 10") |
| meeting_date | Date of the meeting, from meeting_title and the publication id (see details) |
| section | Name of the XML element directly containing the speech (e.g. sak, spm, formalia) |
| case_id | Id of the case the speech belongs to (see get_case), when given in the transcript |
| agenda_no | Agenda item number (from 2016-2017 onward) |
| agenda_merged | Agenda item numbers debated together, comma separated (from 2016-2017 onward) |
| speech_order | Order of the speech element within the transcript |
| speech_part | Order of the speaker within the speech element (usually 1) |
| speech_id | Speech element id (from 2016-2017 onward) |
| speech_type | Type of speech ("hovedinnlegg", "replikk", or "presinnlegg"; see details) |
| speaker_raw | Speaker as written in the transcript |
| speaker_title | Title parsed from speaker_raw (e.g. "Statsråd", "Presidenten") |
| speaker_name | Name parsed from speaker_raw |
| speaker_party | Party parsed from speaker_raw, as a party id of get_all_parties (else NA) |
| speech_time | Time stamp parsed from speaker_raw (hh:mm:ss) |
| person_id | Id of the speaker (see get_mp), when given in the transcript |
| linked_person_id | Id of the speaker, linked from speaker_name (with link = TRUE) |
| link_method | How linked_person_id was linked (with link = TRUE; see speaker_links) |
| chair_name | Name of the sitting chair (president or meeting leader) |
| chair_id | Id of the sitting chair, when given in the transcript |
| chair_linked_id | Id of the sitting chair, linked from chair_name (with link = TRUE) |
| text | Speech text, one line per paragraph |
speaker_links get_publication get_session_publications get_session_meetings get_case
## Not run: speeches <- get_speeches("s140213") head(speeches[, c("speech_type", "speaker_name", "person_id", "linked_person_id")]) # Without the linked ids speeches <- get_speeches("s140213", link = FALSE) ## End(Not run)## Not run: speeches <- get_speeches("s140213") head(speeches[, c("speech_type", "speaker_name", "person_id", "linked_person_id")]) # Without the linked ids speeches <- get_speeches("s140213", link = FALSE) ## 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. |
With keep_sub_topics = TRUE (default), a list with two elements. With keep_sub_topics = FALSE,
only the main topics, as a data.frame with the variables of $main_topics below.
$topics (sub-topics, with the id of their main topic)
| 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 (main 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 |
## Not run: # 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), ] ## End(Not run)## Not run: # 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), ] ## End(Not run)
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, or a vector of strings, indicating the id of the case to request all votes from |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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_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_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, or a vector of strings, indicating the id of the hearing to retrieve. |
good_manners |
Numeric. Seconds delay between calls when making multiple calls to the same function. Note that the Stortinget API is limited to 100 calls per minute (see https://data.stortinget.no/nyhetsoversikt/begrensning-pa-api-kall/). |
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_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
interp0203interp0203
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 status
Question title
Question type
https://data.stortinget.no/eksport/interpellasjoner?sesjonid=2002-2003
A dataset containing all MPs during the 1945-1949 parliamentary period in Stortinget
mps4549mps4549
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_periodsparl_periods
A data frame with 6 columns and 21 rows
Date of data retrieval
Data version from the API
Date period started
Id of the period (used by other functions)
Date period ended
From year to year in full format
https://data.stortinget.no/eksport/stortingsperioder
A dataset containing all parliamentary sessions in Stortinget
parl_sessionsparl_sessions
A data frame with 6 columns and 43 rows (including sessions announced ahead of time)
Date of data retrieval
Data version from the API
Date session started
Id of the session (used by 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(system.file("extdata", "obt_sample.txt", package = "stortingscrape")) head(sample_text) ## End(Not run)## Not run: sample_text <- read_obt(system.file("extdata", "obt_sample.txt", package = "stortingscrape")) head(sample_text) ## End(Not run)
A crosswalk from the names of speakers and chairs, as written in the debate
transcripts (see get_speeches), to person ids, by parliamentary session.
get_speeches adds these links to its output by default (link = TRUE). With
link = FALSE, the dataset can be joined to the output by speaker_name and
session_id (speakers) or by chair_name and session_id (chairs).
speaker_linksspeaker_links
A data frame with 4 columns and 8098 rows
Name as written in the transcripts (speaker_name or chair_name in get_speeches)
Id of the parliamentary session
Id of the person (see get_mp), or NA when the name cannot be linked
How the name was linked: on full name, first and last name, or as a changed name, to an MP roster and/or a minister spell; "ambiguous" when several persons match; "substitute only, no party or title" when not linked for that reason
Names are linked to MPs and substitutes of the session's parliamentary period
(get_parlperiod_mps) and to ministers in office during the session. A name
is linked only when exactly one person matches, first on the full name and
then on first and last name. Names with no such match can still be linked as
a changed name (e.g. a surname added or dropped at marriage): when the first
name is the same, every word of the shorter name is in the longer one, exactly
one MP in the period fits, and the name is written with that MP's party
throughout the session. A name that only matches a substitute registration,
and is never written with a party, a title, or as chair in the session (e.g. a
witness in a hearing), is not linked. There are no manual corrections: names
that cannot be resolved this way (e.g. witnesses in hearings, misspelled names,
and some changed names) have linked_person_id NA.
The links are made from names only and do not use the person_id given in
the transcripts from 2016-2017 onward, which is sometimes wrong.
Ministers and their periods in office come from a list of ministers from 1945 to January 2024, supplemented by the cabinet posts in get_mp_bio for ministers in office after that. The minister data will be updated in a later version.
The dataset covers the transcripts available in the API when it was built (sessions 1998-99 onward). The API's list of transcripts for 2008-2009 fails, so these transcripts were found by their ids, constructed from get_session_meetings; open hearings in that session are therefore missing. Four listed transcripts (s031205, s050526k, s602081, o006051) could not be retrieved from the API.
Built by data-raw/speaker_links.R from the transcripts
(https://data.stortinget.no/dokumentasjon-og-hjelp/publikasjon/), the MPs of each parliamentary
period (https://data.stortinget.no/dokumentasjon-og-hjelp/representanter/), and a list of ministers
and their periods in office from regjeringen.no, supplemented by the coded biographies
(https://data.stortinget.no/dokumentasjon-og-hjelp/kodet-personbiografi/).
## Not run: speeches <- get_speeches("s140213", link = FALSE) speeches <- merge(speeches, speaker_links, by = c("speaker_name", "session_id"), all.x = TRUE) ## End(Not run)## Not run: speeches <- get_speeches("s140213", link = FALSE) speeches <- merge(speeches, speaker_links, by = c("speaker_name", "session_id"), all.x = TRUE) ## End(Not run)
A dataset containing all speeches in the transcript of the Storting's meeting on 13 February 2014 (publication id "s140213"), as returned by get_speeches
speeches140213speeches140213
A data frame with 27 columns and 48 rows (see get_speeches for details)
Date and time of retrieval
Id of the transcript
Id of the parliamentary session
Order of the meeting within the transcript
Meeting id, when given in the transcript
Raw meeting heading
Date of the meeting
Name of the XML element directly containing the speech
Id of the case the speech belongs to, when given in the transcript
Agenda item number (from 2016-2017 onward)
Agenda item numbers debated together (from 2016-2017 onward)
Order of the speech element within the transcript
Order of the speaker within the speech element
Speech element id (from 2016-2017 onward)
Type of speech
Speaker as written in the transcript
Title parsed from speaker_raw
Name parsed from speaker_raw
Party parsed from speaker_raw
Time stamp parsed from speaker_raw
Id of the speaker, when given in the transcript
Id of the speaker, linked from speaker_name (see speaker_links)
How linked_person_id was linked
Name of the sitting chair
Id of the sitting chair, when given in the transcript
Id of the sitting chair, linked from chair_name
Speech text, one line per paragraph
https://data.stortinget.no/eksport/publikasjon?publikasjonid=s140213
A color palette for all (current) parties in the Storting
st_party_colorsst_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
Black; no official color
See list of links above; there are several color alternatives for most parties.
## Not run: seats <- table(get_parlperiod_mps(parl_periods$id[1])$party_id) barplot(seats, col = st_party_colors[names(seats)]) ## End(Not run)## Not run: seats <- table(get_parlperiod_mps(parl_periods$id[1])$party_id) barplot(seats, col = st_party_colors[names(seats)]) ## End(Not run)
A dataset containing vote information on case id 78686 in Stortinget
votevote
A data frame with 22 columns and 3 rows (one per vote)
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=78686
A dataset containing all personal votes for votes 15404, 15405, and 15406 in Stortinget
vote_resultvote_result
A list with three data frames, one per vote (15404, 15405, and 15406), each with 169 rows and the following variables:
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