Hey guys! I'm so close! I'm almost done with this project! Don't worry though, there are 3 more projects so I'll be here for the months to come but I want to get this one done since the others don't have time limits (they are changing this project on the 1st of July so it is no longer available for submission).
Anyways. For the final step, I have to display data from the GoodReads.com API. I have the secret key already. What's the best way to go about including this data? I've never done it before.
Here is what I have to do:
Goodreads Review Data: On your book page, you should also display (if available) the average rating and number of ratings the work has received from Goodreads.
Goodreads API
Goodreads is a popular book review website, and we’ll be using their API in this project to get access to their review data for individual books.
1. Go to https://www.goodreads.com/api and sign up for a Goodreads account if you don’t already have one.
2. Navigate to https://www.goodreads.com/api/keys and apply for an API key. For “Application name” and “Company name” feel free to just write “project1,” and no need to include an application URL, callback URL, or support URL.
3. You should then see your API key. (For this project, we’ll care only about the “key”, not the “secret”.)
4. You can now use that API key to make requests to the Goodreads API, documented here. In particular, Python code like the below
import requests
res = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": " NoDjSCv8OsMB1ZFqjfRxQ", "isbns": "9781632168146"})
print(res.json())
where KEY is your API key, will give you the review and rating data for the book with the provided ISBN number. In particular, you might see something like this dictionary:
{'books': [{
'id': 29207858,
'isbn': '1632168146',
'isbn13': '9781632168146',
'ratings_count': 0,
'reviews_count': 1,
'text_reviews_count': 0,
'work_ratings_count': 26,
'work_reviews_count': 113,
'work_text_reviews_count': 10,
'average_rating': '4.04'
}]
}
Note that work_ratings_count here is the number of ratings that this particular book has received, and average_rating is the book’s average score out of 5.
Anyways. For the final step, I have to display data from the GoodReads.com API. I have the secret key already. What's the best way to go about including this data? I've never done it before.
Here is what I have to do:
Goodreads Review Data: On your book page, you should also display (if available) the average rating and number of ratings the work has received from Goodreads.
Goodreads API
Goodreads is a popular book review website, and we’ll be using their API in this project to get access to their review data for individual books.
1. Go to https://www.goodreads.com/api and sign up for a Goodreads account if you don’t already have one.
2. Navigate to https://www.goodreads.com/api/keys and apply for an API key. For “Application name” and “Company name” feel free to just write “project1,” and no need to include an application URL, callback URL, or support URL.
3. You should then see your API key. (For this project, we’ll care only about the “key”, not the “secret”.)
4. You can now use that API key to make requests to the Goodreads API, documented here. In particular, Python code like the below
import requests
res = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": " NoDjSCv8OsMB1ZFqjfRxQ", "isbns": "9781632168146"})
print(res.json())
where KEY is your API key, will give you the review and rating data for the book with the provided ISBN number. In particular, you might see something like this dictionary:
{'books': [{
'id': 29207858,
'isbn': '1632168146',
'isbn13': '9781632168146',
'ratings_count': 0,
'reviews_count': 1,
'text_reviews_count': 0,
'work_ratings_count': 26,
'work_reviews_count': 113,
'work_text_reviews_count': 10,
'average_rating': '4.04'
}]
}
Note that work_ratings_count here is the number of ratings that this particular book has received, and average_rating is the book’s average score out of 5.