Querying APIs in R

library(tidyverse) ; library(httr) ; library(jsonlite)
path <- "https://data.police.uk/api/crimes-street/burglary?"
request <- GET(url = path, 
query = list(
lat = 53.421813,
lng = -2.330251,
date = "2018-05")
)
request$status_code
response <- content(request, as = "text", encoding = "UTF-8")
df <- fromJSON(response, flatten = TRUE) %>% 
data.frame()
df <- select(df,
month, category,
location = location.street.name,
long = location.longitude,
lat = location.latitude)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store