Im trying to retrieve data from an import.io 'connector' API.
Basically, i've trained the extractor to the structure of a given website, and I want to import the data from within R using this approach:
1) Retrieve the Json results from the API
2) Save each query-result into a given dataframe
My plan was to use RCurl for querying the API-link:
https://api.import.io/store/connector/9128b4e0-9ae2-4232-b202-c1e8766ed01f/_query?input=webpage/url:[ENCODED URL]&&_apikey=[API-KEY]
require(Rcurl)
Raw.Data <- curl::curl(url = "https://api.import.io/store/connector/9128b4e0-9ae2-4232-b202-c1e8766ed01f/_query?input=webpage/url:[ENCODED URL]&&_apikey=[API-KEY]")
require(rjson)
FromJson_To_DataFrame <-(Raw.data)
I found an answer to this problem, which is fairly straightforward. The json object retrieved from the import.io API can be changed in to coulums in a DF by accesing it via $:
library(httr)
output <- get(https://api.import.io/store/connector/9128b4e0-9ae2-4232-b202-c1e8766ed01f/_query?input=webpage/url:[ENCODED URL]&&_apikey=[API-KEY])
result <- content(output)
vector1 <- result$results$variable1
vector2 <- result$results$variable2
and then you can cbind them to a dataframe if you need to.