Chapter 1 Introduction

This project APIs for Social Scientists: A collaborative Review is an outcome of the seminar Computational Social Science (CSS) taught at the University of Mannheim in 2021. While teaching the seminar we had trouble finding short reviews of APIs with quick R-code examples. Fortunately, almost everyone participating in the seminar was motivated enough to write a quick API review. Hopefully, our resource will be help future students to start diving into different APIs.

Below we review different data- and service-APIs that may be useful to social scientists. The chapters always include a simple R code example as well as references to social science research that has relied on them. The idea is to provide short reviews of max. 10 pages for the corresponding API with code to get you started. Each chapter follows a systematic set of questions:

  • What data/service is provided by the API? (+ who provides it?)
  • What are the prerequisites to access the API (e.g., authentication)?
  • What does a simple API call look like?
  • How can we access the API from R (httr + other packages)?
  • Are there social science research examples using the API?

1.1 Prerequisites: Authentication

A lot of the APIs require that you authenticate with the API provider. The underlying script of this review is written in such a way that it contains R chunks for authentication, however they will not be visible in the examples below (we only show placeholders for you to recognize at which step you will need to authenticate). These chunks in most cases make use of so-called keys in JSON format (e.g., service account key for Google APIs). However cloning the corresponding repository of this review will not result in giving you the keys, hence in order to replicate our API calls, you will have to generate and use your own individual keys.

1.2 Prerequisites: Software & packages

The code examples rely R and different packages thereof. It’s probably easiest if you install all of them in one go using the code below. The p_load() function (pacman package) checks whether packages are installed. If not they are installed and loaded.

# install.packages('pacman')
library(pacman)
p_load('httr', 'memoise',
'googleway', 'httr', 'tidyverse', 'ckanr', 'jsonlite', 'readxl', 'curl', 'httr',
'devtools', 'RCrowdTangle', 'dplyr', 'jsonlite', 'httr', 'remotes', 'dplyr',
'ggplot2', 'tidyr', 'Radlibrary', 'dplyr', 'tidyr', 'DT', 'DemografixeR',
'jsonlite', 'httr', 'httr', 'dplyr', 'httr', 'googleLanguageR', 'tidyverse',
'tm', 'ggwordcloud', 'httr', 'ggplot2', 'tidyverse', 'googleway', 'mapsapi',
'stars', 'tidyverse', 'googleLanguageR', 'googleLanguageR', 'httr', 'gtrendsR',
'ggplot2', 'dplyr', 'httr', 'httr', 'httr', 'stringr', 'mediacloud', 'tidytext',
'quanteda', 'quanteda', 'httr', 'academictwitteR', 'tidyverse', 'lubridate',
'tidyverse', 'lubridate', 'rtweet', 'WikipediR', 'rvest', 'xml2', 'httr',
'jsonlite', 'here', 'dplyr', 'ggplot2', 'tuber', 'tidyverse', 'purrr')
p_load_gh("quanteda/quanteda.corpora")
p_load_gh("cbpuschmann/RCrowdTangle")
p_load_gh("joon-e/mediacloud")
p_load_gh("facebookresearch/Radlibrary")