Skip to content

About

An R package to access Italian Parliament open data via SPARQL, covering both the Camera dei Deputati and the Senato della Repubblica.

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

italyParlR italyParlR logo

An R package to access Italian Parliament open data via SPARQL, covering both the Camera dei Deputati and the Senato della Repubblica.

Installation

# install.packages("remotes")
remotes::install_github("paride92/italyParlR")

Data sources

Chamber Portal SPARQL endpoint
Camera dei Deputati dati.camera.it https://dati.camera.it/sparql
Senato della Repubblica dati.senato.it http://dati.senato.it/sparql

Both portals publish data under a Creative Commons BY licence.

Function reference

Functions follow a two-prefix convention:

  • cd_*() — Camera dei Deputati
  • sn_*() — Senato della Repubblica

Camera dei Deputati (cd_*)

Function Description
cd_query(query) Raw SPARQL query
cd_legislatures() All legislatures
cd_deputies(legislature, limit, offset) Deputies with mandate & election info
cd_deputy(uri) All properties of one deputy
cd_deputy_mandates(uri) All mandates for one deputy
cd_deputy_search(name, legislature) Search deputies by name
cd_deputy_group(deputy_uri, legislature) Groups a deputy belongs to
cd_groups(legislature) Parliamentary groups
cd_group_members(group_uri, legislature) Deputies in a group
cd_roles(deputy_uri, group_uri, legislature) Roles and appointments (incarichi)
cd_government_members(legislature) Government members
cd_bills(legislature, type, limit, offset) Bills (atti)
cd_bill(uri) All properties of one bill
cd_bills_by_deputy(deputy_uri, legislature) Bills sponsored by a deputy
cd_aic(deputy_uri, primary_only, legislature) Atti di indirizzo e controllo
cd_documents(deputy_uri, legislature) Parliamentary documents (DOC)
cd_votes(legislature, approved, limit, offset) Roll call vote sessions
cd_vote_detail(vote_uri) Individual MP votes for a session
cd_sessions(legislature, limit, offset) Parliamentary sessions (sedute)
cd_speeches(legislature, session_uri, deputy_uri) Speeches (interventi)

Senato della Repubblica (sn_*)

Function Description
sn_query(query) Raw SPARQL query
sn_senators(legislature, active_only, limit, offset) Senators with biographical & mandate info
sn_senator(uri) All properties of one senator
sn_senator_mandates(uri) All mandates for one senator
sn_senator_search(name, legislature) Search senators by name
sn_groups(legislature, active_only) Parliamentary groups
sn_group_members(group_uri, legislature, active_only, limit, offset) Members of a group
sn_committees(senator_uri, legislature, active_only, limit, offset) Committee memberships
sn_bills(legislature, branch, limit, offset) Bills (DDL)
sn_bill_signatories(bill_uri) Signatories of a bill
sn_bill_progress(bill_uri) Legislative progress (iter) of a bill
sn_votes(legislature, limit, offset) Electronic vote sessions
sn_sessions(legislature, limit, offset) Assembly sessions (sedute)
sn_speeches(legislature, session_uri, limit, offset) Speeches (interventi) in assembly sessions
sn_aic(legislature, type, limit, offset) Sindacato ispettivo (interrogazioni, interpellanze, mozioni)
sn_amendments(legislature, topic_uri, limit, offset) Amendments (emendamenti) for a bill or legislature

Quick start

Camera dei Deputati

library(italyParlR)

# All legislatures
legs <- cd_legislatures()

# Deputies from legislature 19 — includes mandate start, validation, election info
deps <- cd_deputies(legislature = 19, limit = 50)
head(deps[, c("first_name", "last_name", "gender", "election_label")])

# Full mandate history for one deputy
cd_deputy_mandates("http://dati.camera.it/ocd/deputato.rdf/d307511_19")

# Search a deputy by name
cd_deputy_search("Meloni", legislature = 19)

# Parliamentary groups and their members
cd_groups(legislature = 19)
cd_group_members(legislature = 19)

# Which group does a deputy belong to?
cd_deputy_group("http://dati.camera.it/ocd/deputato.rdf/d306921_17")

# Bills
cd_bills(legislature = 19, limit = 100)
cd_bills(legislature = 19, type = "Proposta di Legge")

# Bills sponsored by a deputy
cd_bills_by_deputy("http://dati.camera.it/ocd/deputato.rdf/d306921_17")

# Atti di indirizzo e controllo (interrogazioni, interpellanze, mozioni...)
cd_aic(legislature = 19)
cd_aic(deputy_uri = "http://dati.camera.it/ocd/deputato.rdf/d306921_17")

# Roll call votes
cd_votes(legislature = 19, limit = 50)
cd_votes(legislature = 19, approved = TRUE)          # only approved
cd_vote_detail("http://dati.camera.it/ocd/votazione.rdf/vs17_243_001")

# Parliamentary sessions and speeches
cd_sessions(legislature = 19, limit = 20)
cd_speeches(legislature = 19, limit = 50)

# Government members and roles
cd_government_members(legislature = 19)
cd_roles(legislature = 19)

Senato della Repubblica

# Active senators in legislature 19 — includes gender, birth_date, birth_city,
# photo, election_type, election_region
sn_senators(legislature = 19)

# All senators of legislature 17 (including those whose mandate ended)
sn_senators(legislature = 17, active_only = FALSE)

# Full mandate history for one senator (Senate + Camera mandates)
sn_senator_mandates("http://dati.senato.it/osr/senatore/25429")

# Search a senator by name
sn_senator_search("Renzi")

# Parliamentary groups
sn_groups(legislature = 19)
sn_group_members(legislature = 19)

# Committee memberships
sn_committees(legislature = 19)
sn_committees(senator_uri = "http://dati.senato.it/osr/senatore/1234")

# Bills (DDL)
sn_bills(legislature = 19)
sn_bills(legislature = 19, branch = "S")   # Senate-originated only

# Signatories and legislative progress of a bill
sn_bill_signatories("http://dati.senato.it/ddl/44347")
sn_bill_progress("http://dati.senato.it/ddl/44347")

# Electronic votes
sn_votes(legislature = 19, limit = 100)

# Assembly sessions (sedute)
sn_sessions(legislature = 19)

# Speeches in a legislature or specific session
sn_speeches(legislature = 19, limit = 50)
sn_speeches(session_uri = "http://dati.senato.it/sedutaassemblea/24248")

# Sindacato ispettivo (interrogazioni, interpellanze, mozioni, risoluzioni)
sn_aic(legislature = 19)
sn_aic(legislature = 19, type = "Interrogazione")
sn_aic(legislature = 19, type = "Mozione")

# Amendments (emendamenti) for a legislature or specific bill topic
sn_amendments(legislature = 19)
sn_amendments(topic_uri = "http://dati.senato.it/oggettotrattazione/1186716")

Raw SPARQL queries

Both cd_query() and sn_query() accept any SPARQL SELECT string for full flexibility:

# Camera
cd_query("
  SELECT ?s ?label
  WHERE {
    ?s a <http://dati.camera.it/ocd/governo> .
    ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label .
  }
  LIMIT 10
")

# Senato
sn_query("
  SELECT ?s ?label
  WHERE {
    ?s a <http://dati.senato.it/osr/Senatore> .
    ?s <http://xmlns.com/foaf/0.1/lastName> ?label .
  }
  LIMIT 10
")

Legislature numbers

Number Period
19 2022 – present
18 2018 – 2022
17 2013 – 2018
16 2008 – 2013
… …

Use cd_legislatures() for the full Camera list including historic legislatures. For the Senate, the legislature is an integer used directly in the query (e.g. sn_senators(legislature = 19)).

Pagination

All list functions support limit and offset:

# Camera: paginate through bills
page1 <- cd_bills(legislature = 19, limit = 100, offset = 0)
page2 <- cd_bills(legislature = 19, limit = 100, offset = 100)

# Senate: paginate through senators
page1 <- sn_senators(legislature = 19, limit = 100, offset = 0)
page2 <- sn_senators(legislature = 19, limit = 100, offset = 100)

About

An R package to access Italian Parliament open data via SPARQL, covering both the Camera dei Deputati and the Senato della Repubblica.

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages