A site for readers and writers that's been around since 2007, Goodreads, now owned by Amazon, lets users track books, rate and review them, network with readers and search their extensive database. It is a social network in addition to being a personal book tracking system. And just this week (5/17/16), Goodreads Deals was launched, e-mailing users when ebooks go to discount. For a book reader, it's a potential resource, but for a developer it's a warehouse of book data and a thriving community of book lovers. We'll be just dipping our toe into this enormous capacity in this introductory tutorial to the Goodreads API! So first, please check out the site! Create an account -- it's easy and can be done in seconds via the button below!
Before we start, let's talk briefly about CORS, or "cross-origin resource sharing." It is a security system in place on most browsers that prevents some web data from being exchanged ACROSS domains. That is, we can't easily request our book data from Goodreads (or most APIs) from outside their site. It is our own browsers that stop it. For the purposes of this tutorial, please use Chrome to view the examples, and click the link below if you haven't already to install a free plug-in that allows this security feature to be temporarily bypassed. All of the examples on the site function as designed, so if you're having a problem with them responding, please make sure you're in Chrome, and have this feature enabled! Thank you, and let's get to the fun part!
In this tutorial, we're going to leverage the incredible pool of information that Goodreads has amassed. Even better -- I'm going to show you how to domains it, in a parlance that even a beginner could follow! More specifically, we're going to focus on a client-side access of the Goodreads API to make a search engine, that let's a user pick to search by title, author, or all, and returns Goodreads's search results, along with the average review of each book! We'll also look at some server-side code and cover a variety of topics central to this process -- like handling the varying kinds of data Goodreads will send back to you. But first, let's talk about what an API even is! Onward!