Package: goodreads2
This package provides a Python interface for theGoodreads
API. Using it, you can do pretty much
anything that Goodreads allows to do with their own data.DependenciesThis package depends on the following packages:xmltodictrequestsrauthThey can be installed usingpip.sudo pip install -r requirements.txtIf you want to contribute to this package, you will need thenosepackage as well.InstallationTo install, run the following command from the top-level package
directory.sudo python setup.py installGetting StartedThe first thing is to request an API key from Goodreadshere. Once you have it, you can
create a client instance to query Goodreads.fromgoodreadsimportclientgc=client.GoodreadsClient(<api_key>,<api_secret>)To access some of the methods, you needOAuthfor authorization.gc.authenticate(<access_token>,<access_token_secret>)Note thataccess_tokenandaccess_token_secretare 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 him/her
to authorize your app and save the returningaccess_tokenandaccess_token_secretin your database.ExamplesThis package provides a Python interface for most Goodreads API methods.
Here are a few examples demonstrating how to access data on Goodreads.BooksLet’s access the first book added to Goodreads! It is the book with id
1.book=gc.book(1)Once you have theGoodreadsBookinstance for the book, you can
access data for the queried book.>>>book.titleu'Harry Potter and the Half-Blood Prince (Harry Potter, #6)'>>>authors=book.authors>>>authors[0].nameu'J.K. Rowling'>>>book.average_ratingu'4.49'AuthorsYou can get information about an author as well.>>>author=gc.author(2617)>>>author.nameu'Jonathan Safran Foer'>>>author.works_countu'13'>>>author.books[ExtremelyLoudandIncrediblyClose,EverythingIsIlluminated,EatingAnimals,TreeofCodes,EverythingisIlluminated&ExtremelyLoudandIncrediblyClose,Theunabridgedpocketbookoflightning,TheFutureDictionaryofAmerica,AConvergenceofBirds:OriginalFictionandPoetryInspiredbyJosephCornell,NewAmericanHaggadah,TheSixthBorough]UsersUser data can be retrieved by user id or username.>>>user=gc.user(1)>>>user.nameu'Otis Chandler'>>>user.user_nameu'otis'>>>user.small_image_urlu'http://d.gr-assets.com/users/1189644957p2/1.jpg'GroupsLet’s find a group discussing Python and get more information about it.>>>g=gc.find_groups("Python")>>>g=groups[0]>>>g['title']u'The Computer Scientists'>>>group=gc.group(g['id'])>>>group.descriptionu'Only for Committed Self Learners and Computer Scientists Who are Starving forInformation,andWanttoAdvancetheirSkillsThrough:Reading,PracticingandDiscussionComputerScienceandProgrammingBooks.'EventsGoodreads API also allows to list events happening in an area.>>>events=gc.list_events(21229)>>>event=events[0]>>>event.titleu'Books and Cocktails'>>>event.addressu'120 N. Front St.'>>>event.cityu'Wrightsville'DocumentationRead more about this packagehere.ContributionIf 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.LicenseMIT LicenseAcknowledgmentThanks toPaul ShannonandSefa Kilicfor
providing ‘goodreads’ package at PyPI.