knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
deanslistr
is an R package that wraps the DeansList RESTful HTTP API for use in R programming. It is currently under active development by Chris Haid at KIPP Chicago with the hope of releasing it on CRAN.
Installation is easy:
if(!require(devtools)) install_packages('devtools') devtools::install_github('chrishaid/deanslistr')
Usage is straightforward for version 1 API endpoints. You simply pass the last portion the endoint path to the endpoint
paramater of the deanslist_api()
function, along with your domain and API access key:
library(deanslistr) dla_key <- Sys.getenv("KEY_DLA") x <- deanslist_api(endpoint = 'suspensions', domain = 'dlacademy', key = dla_key) x
Notice that while the deanslist_api()
will try to coerce nested JSON to a data frame, some fields may be stored as lists (e.g., Penalties
and Actions
in the above response). So pay attion to the content that's returned; you might need to do some more munging with something like tidyr::unnest()
The remaing beta endpoints are taken processed on a case by case basis and require passing the endpoint_version = 'beta'
to the deanslist_api()
:
x <- deanslist_api(endpoint = 'users', domain = 'dlacademy', key = dla_key, endpoint_version = 'beta') x
The package has some convenience functions that wrap deanslist_api()
for specific endpoints. These wrappers all start with a get_
prefix. The first (and curruntly only) wrapper is get_suspensions
. The onus for these functions is to facilitate calling deanslist_api
for multiple schools. If you have six schools you will need to provide 6 keys to deanslist_api
, one-at-a-time. the get_
functions can take take multiple keys via the key_list
parameter. Better still, you can store keys in .Renviron
file, which will be sourced when R starts (if saved in a users home directory). The keys' variables need to fit hte pattern of DL_KEY_
where the SCHOOL
bit can be any test string. get_
wrappers, if not passed a list of keys explicitely, will look to your environment variables for keys stored in the DL_KEY_
variables and requirest the data from DeansList and (try to) store the returned data as a list of data frames. This list of data frames is best handled with purrr
or other tidyverse
functions.
x <- get_suspensions(domain = 'dlacademy`)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.