# You will need to get your own API key by creating an account at api.blockspring.com | |
# install.packages(c("httr", "RJSONIO")) | |
library(httr) | |
library(RJSONIO) | |
mtcars_aaS <- function(api_key, mpg_min = "0", mpg_max = "10e6", | |
cyl_min = "0", cyl_max = "10e6", | |
disp_min = "0", disp_max = "10e6", | |
hp_min = "0", hp_max = "10e6", | |
drat_min = "0", drat_max = "10e6", | |
wt_min = "0", wt_max = "10e6", | |
qsec_min = "0", qsec_max = "10e6", | |
vs_min = "0", vs_max = "10e6", | |
am_min = "0", am_max = "10e6", | |
gear_min = "0", gear_max = "10e6", | |
carb_min = "0", carb_max = "10e6"){ | |
data <- list(mpg_min = mpg_min, mpg_max = mpg_max, | |
cyl_min = cyl_min, cyl_max = cyl_max, | |
disp_min = disp_min, disp_max = disp_max, | |
hp_min = hp_min, hp_max = hp_max, | |
drat_min = drat_min, drat_max = drat_max, | |
wt_min = wt_min, wt_max = wt_max, | |
qsec_min = qsec_min, qsec_max = qsec_max, | |
vs_min = vs_min, vs_max = vs_max, | |
am_min = am_min, am_max = am_max, | |
gear_min = gear_min, gear_max = gear_max, | |
carb_min = carb_min, carb_max = carb_max) | |
# This post request could be much more eloquent, I would sincerely appreciate any httr help! | |
post <- POST("https://sender.blockspring.com/api/blocks/b71b0fc28a18e6d58b1dbf55e7c00c59", | |
query=list(api_key=api_key), config(postfields = toJSON(data), | |
httpheader = c('Content-Type' = 'application/json'))) | |
data.frame(fromJSON(content(post, as = "text"))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment