0

I am using httr in order access data from an api and then save that data so that I can begin to do some data validation. I am having an issue accessing the columns and rows I think because the data has been stored as a nested list.

query2 <- "this is where my api key in addition to the website I was trying went "
out2 <- GET(url = query2)
http_status(out2)
$category
[1] "Success"

$reason
[1] "OK"

$message
[1] "Success: (200) OK"

dataContent <- content(out2)
names(dataContent)
[1] "Data"

envData <- jsonlite::fromJSON(toJSON(dataContent))
result <- data.frame(envData)
names(result)
[1] "Data.Providers.Name"    "Data.Providers.Type"   
[3] "Data.Providers.Owner"   "Data.Providers.Records"
# when I view the data I can see it in rows and columns
View(result$Data.Providers.Records)

#for some reason its saved as one object and I cannot access individual         rows and columns 
length(cleanerData)
[1] 1
N.M
  • 1

1 Answers1

0

I can't replicate your example with what you have at the moment, but you can probably get the data.frame you are expecting by using fromJSON's flatten = TRUE

query2 <- "api-url"
out2 <- GET(url = query2)

## assuming its JSON content, parse as text and use fromJSON
dataContent <- content(out2, as = "text")
parsed_content <- jsonlite::fromJSON(dataContent, flatten = TRUE)
MarkeD
  • 2,500
  • 2
  • 21
  • 35