In my computing class I spend two days on obtaining data from the web (i.e. API requests, web scraping). I used to use the OMDB API because it didn't require authentication, queries were built very easily in the url, and the response converted very nicely to a one row data frame without any hassle. However a) it moved last year to a paid API (which wasn't a huge problem, they gave me an API key for teaching demo purposes), and b) they added a new ratings field which causes the response to take on a nested list format:
{
"Title": "Sharknado",
"Year": "2013",
"Rated": "TV-14",
"Released": "11 Jul 2013",
"Runtime": "86 min",
"Genre": "Comedy, Horror, Sci-Fi",
"Director": "Anthony C. Ferrante",
"Writer": "Thunder Levin",
"Actors": "Ian Ziering, Tara Reid, John Heard, Cassandra Scerbo",
"Plot": "When a freak hurricane swamps Los Angeles, nature's deadliest killer rules sea, land, and air as thousands of sharks terrorize the waterlogged populace.",
"Language": "English",
"Country": "USA",
"Awards": "1 win & 2 nominations.",
"Poster": "https://images-na.ssl-images-amazon.com/images/M/MV5BOTE2OTk4MTQzNV5BMl5BanBnXkFtZTcwODUxOTM3OQ@@._V1_SX300.jpg",
"Ratings": [
{
"Source": "Internet Movie Database",
"Value": "3.3/10"
},
{
"Source": "Rotten Tomatoes",
"Value": "82%"
}
],
"Metascore": "N/A",
"imdbRating": "3.3",
"imdbVotes": "38,601",
"imdbID": "tt2724064",
"Type": "movie",
"DVD": "03 Sep 2013",
"BoxOffice": "N/A",
"Production": "NCM Fathom",
"Website": "http://www.mtivideo.com/TitleView.aspx?TITLE_ID=728",
"Response": "True"
}
which does not convert easily to a flat data frame easily using fromJSON()
and as_tibble()
(I have to convert the Ratings list element to NULL
first). Obviously most APIs have this type of structure and I plan to go through these more complex structures with the students, using purrr
functions to assist in the flattening process (I love Jenny Bryan's purrr
tutorials), however for just an initial demo I'd prefer an API that returns a simple, flat structure. Anyone have recommendations for such an API?