Skip to main content

Python wrapper for Goodreads API

Project description

Build Status Coverage Status Documentation Status

http://s.gr-assets.com/assets/icons/goodreads_icon_50x50-823139ec9dc84278d3863007486ae0ac.png

This package provides a Python interface for the Goodreads API. Using it, you can do pretty much anything that Goodreads allows to do with their own data.

Dependencies

This package depends on the following packages:

  • xmltodict

  • requests

  • rauth

They can be installed using pip.

sudo pip install -r requirements.txt

If you want to contribute to this package, you will need the nose package as well.

Installation

To install, run the following command from the top-level package directory.

sudo python setup.py install

Getting Started

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.

gc.authenticate(<access_token>, <access_token_secret>)

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 him/her to authorize your app and save the returning access_token and access_token_secret in your database.

Examples

This package provides a Python interface for most Goodreads API methods. Here are a few examples demonstrating how to access data on Goodreads.

Books

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[0].name
u'J.K. Rowling'
>>> book.average_rating
u'4.49'

Authors

You can get information about an author as well.

>>> author = gc.author(2617)
>>> author.name
u'Jonathan Safran Foer'
>>> author.works_count
u'13'
>>> author.books
[Extremely Loud and Incredibly Close, Everything Is Illuminated, Eating Animals, Tree of Codes, Everything is Illuminated & Extremely Loud and Incredibly Close, The unabridged pocketbook of lightning, The Future Dictionary of America, A Convergence of Birds: Original Fiction and Poetry Inspired by Joseph Cornell, New American Haggadah, The Sixth Borough]

Users

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'

Groups

Let’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.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.'

Events

Goodreads API also allows to list events happening in an area.

>>> events = gc.list_events(21229)
>>> event = events[0]
>>> event.title
u'Books and Cocktails'
>>> event.address
u'120 N. Front St.'
>>> event.city
u'Wrightsville'

Documentation

Read more about this package here.

Contribution

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.

License

MIT License

Acknowledgment

Thanks to Paul Shannon and Sefa Kilic for providing ‘goodreads’ package at PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goodreads2-0.3.4.zip (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goodreads2-0.3.4-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file goodreads2-0.3.4.zip.

File metadata

  • Download URL: goodreads2-0.3.4.zip
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for goodreads2-0.3.4.zip
Algorithm Hash digest
SHA256 9517ba12630f0edfce7aa202f6dd194cff48bc6207738247dce11f47264b9e64
MD5 03d437d0db8eb9ff011e0fb2a970ac34
BLAKE2b-256 5626c3ef6a7bb9c6cc6cbcd86dcaa643b07d8b0d0da09c368607d113cbc217b5

See more details on using hashes here.

File details

Details for the file goodreads2-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for goodreads2-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 381fbb92c824a367d50cedf0677ab75d50eadbdaf0af5fbb804854a54f67e060
MD5 c3e22544fcef2c2aa50558c596871a49
BLAKE2b-256 b1212717d15ae022ce074d9f0411c33e8a4c09a14d26cc7ef874006b479b50af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page