Goodreads API wrapper
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 11 commits ahead, 94 commits behind sosedoff:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
README.md
Rakefile
goodreads.gemspec

README.md

Goodreads API wrapper

Ruby library to connect with Goodreads API.

Build Status

Installation

You can install this library via rubygems:

gem install goodreads

Or using rake:

rake install

Getting Started

In order to use Goodreads API you must obtain an API key for your account.

Setup client:

client = Goodreads::Client.new(:api_key => 'YOUR_KEY')

# or using a shortcut
client = Goodreads.new(:api_key => 'YOUR_KEY')

Global configuration

Library allows you to define a global configuration options.

Goodreads.configure(:api_key => 'YOUR_KEY')

Get current options:

Goodreads.configuration # => {:api_key => 'YOUR_KEY'}

In case you need to reset options:

Goodreads.reset_configuration

Usage

Lookup books

Find a book by ISBN:

book = client.book_by_isbn('ISBN')

Find a book by Goodreads ID:

book = client.book('id')

Find a book by title:

book = client.book_by_title('Book title')

Search for books (by title, isbn, genre):

search = client.search_books('Your search query')
search.results.work.each do |book|
  book.id        # => book ID
  book.title     # => book title
end

Reviews

Pull recent reviews:

client.recent_reviews.each do |r|
  r.id            # => review id
  r.book.title    # => review book title
  r.body          # => review message
  r.user.name     # => review user name
end

Get review details:

review = client.review('id')
review.id         # => ID
review.user       # => User information
review.book       # => Book information
review.rating     # => User rating

Shelves

Get the books on a user's shelf:

shelf = client.shelf(user_id, shelf_name)
shelf.books  # array of books on this shelf
shelf.start  # start index of this page of paginated results
shelf.end    # end index of this page of paginated results
shelf.total  # total number of books on this shelf

User Id

Get the user id of the user who authorized via OAuth:

client = Goodreads::Client.new(:api_key => 'YOUR_KEY', :oauth_token => token)
client.user_id  # id of user who authorized via OAuth

token is an instance of OAuth::AccessToken. See the Goodreads documentation for examples of how to correct create one.

Contributions

Feel free to contribute any patches or new features.

Make sure to add a test coverage so it does not break any existing code.

For documentation please visit API Reference

License

Copyright © 2011-2012 Dan Sosedoff.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.