cecilialee
2/8/2018 - 11:52 PM

Use morph.io API in R

Use morph.io API in R with httr. Then convert the content to a dataframe with jsonlite. Turn it to tibble for easier analysis. #r #httr #jsonlite

library(httr)
library(jsonlite)

resp <- GET("https://api.morph.io/cecilialee/morph-scraper/data.json",
            query = list("query" = "select * from 'data'",
                         "key" = "Kiu/NDU9OrgwJCJ1X/+2"))  # fake API
dshk <- content(resp, as = "text")
dshk_df <- fromJSON(dshk)

# library(tidyverse)
# dshk_tbl <- as.tibble(dshk_df)