Python 3 wrapper for Goodreads API
This package provides a Python interface for the Goodreads API. Using it, you can do pretty much anything that Goodreads allows through their public API.
This package is largely Python 2 compatible, but is only officially supported for Python 3.
BetterReads is an expansion of the goodreads2 package available on PyPi. That package is no longer maintained and needed some updates to be usable. The name is just cheeky and cute, and not to imply that this project is substantially better than any other project. Someday I hope it’s succeeded by a Python package called BestReads.
Major updates in this new project:
- Use https for Oauth - goodreads now requires this and previous packages’ Oauth requests always fail
- Add convenience method to get all of a user’s reviews for a specific shelf
This package depends on the following packages:
They can be installed using pip.
sudo pip install -r requirements.txt
If you want to contribute to this package, you will need to install the packages in requirements-dev.txt as well.
To install, run the following command from the top-level package directory.
sudo python setup.py install
You can also install BetterReads using pip. The current version on PyPi is 0.4.1.
pip install betterreads
The first thing is to request an API key from Goodreads here. Once you have it, you can create a client instance to query Goodreads.
from goodreads import client gc = client.GoodreadsClient(<api_key>, <api_secret>)
To access some of the methods, you need OAuth for authorization.
Note that access_token and access_token_secret are different from developer key and secret. For the development step, you can call the same function with no parameters to get authorization. It will open a URL pointing a Goodreads page for OAuth permission. For your application, you can direct the user to that particular URL, ask them to authorize your app and save the returning access_token and access_token_secret in your database.
This package provides a Python interface for most Goodreads API methods. Here are a few examples demonstrating how to access data on Goodreads.
Let’s access the first book added to Goodreads! It is the book with id 1.
book = gc.book(1)
Once you have the GoodreadsBook instance for the book, you can access data for the queried book.
>>> book.title u'Harry Potter and the Half-Blood Prince (Harry Potter, #6)' >>> authors = book.authors >>> authors.name u'J.K. Rowling' >>> book.average_rating u'4.49'
User data can be retrieved by user id or username.
>>> user = gc.user(1) >>> user.name u'Otis Chandler' >>> user.user_name u'otis' >>> user.small_image_url u'http://d.gr-assets.com/users/1189644957p2/1.jpg'
Let’s find a group discussing Python and get more information about it.
>>> g = gc.find_groups("Python") >>> g = groups >>> g['title'] u'The Computer Scientists' >>> group = gc.group(g['id']) >>> group.description u'Only for Committed Self Learners and Computer Scientists Who are Starving for Information, and Want to Advance their Skills Through: Reading, Practicing and Discussion Computer Science and Programming Books.'
Goodreads API also allows to list events happening in an area.
>>> events = gc.list_events(21229) >>> event = events >>> event.title u'Books and Cocktails' >>> event.address u'120 N. Front St.' >>> event.city u'Wrightsville'
Read more about this package here.
If you find an API method that is not supported by this package, feel free to create a Github issue. Also, you are more than welcome to submit a pull request for a bug fix or additional feature. For more detail on contributing to this project and setting up your local dev environment, check out our contribution guide.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size betterreads-0.4.2-py3-none-any.whl (16.3 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size betterreads-0.4.2.tar.gz (15.3 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for betterreads-0.4.2-py3-none-any.whl