Coder Social home page Coder Social logo

goodreads's Introduction

Goodreads Build Status

Ruby wrapper to communicate with Goodreads API.

Installation

Install gem with rubygems:

gem install goodreads

Or manually:

rake install

Getting Started

Before using Goodreads API you must create a new application. Visit signup form for details.

Setup client:

client = Goodreads::Client.new(:api_key => 'KEY', :api_secret => 'SECRET')
client = Goodreads.new(:api_key => 'KEY') # short version

Global configuration

You can define client credentials on global level. Just create an initializer file (if using rails) under config/initializers:

Goodreads.configure(
  :api_key => 'KEY',
  :api_secret => 'SECRET'
)

Get global configuration:

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

In case you need to reset options:

Goodreads.reset_configuration

Usage

Lookup books

You can lookup a book by ISBN, ID or Title:

client.book('id')
client.book_by_isbn('ISBN')
client.book_by_title('Book title')

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

search = client.search_books('The Lord Of The Rings')

search.results.work.each do |book|
  book.id        # => book id
  book.title     # => book title
end

Authors

Look up an author by their Goodreads Author ID:

author = client.author('id')

author.id              # => author id
author.name            # => author's name
author.link            # => link to author's Goodreads page
author.fans_count      # => number of fans author has on Goodreads
author.image_url       # => link to image of the author
author.small_image_url # => link to smaller of the author
author.about           # => description of the author
author.influences      # => list of links to author's influences
author.works_count     # => number of works by the author in Goodreads
author.gender          # => author's gender
author.hometown        # => author's hometown
author.born_at         # => author's birthdate
author.died_at         # => date of author's death

Look up an author by name:

author = client.author_by_name('Author Name')

author.id     # => author id
author.name   # => author name
author.link   # => link to author's Goodreads page

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         # => review id
review.user       # => user information
review.book       # => uook 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

Groups

Get group details:

group = client.group('id')

group.id                 # => group id
group.title              # => group title
group.access             # => group's access settings
                         # => (e.g., public or private)
group.group_users_count  # => number of users in the group

List the groups a given user is a member of:

group_list = client.group_list('user_id', 'sort')

group_list.total         # => total number of groups
group_list.group.count  # => number of groups returned in the request

# Loop through the list to get details for each of the groups.

group_list.group.each do |g|
  g.id                 # => group id
  g.access             # => access settings (private, public)
  g.users_count        # => number of members
  g.title              # => title
  g.image_url          # => url of the group's image
  g.last_activity_at   # => date and time of the group's last activity
end

The sort parameter is optional, and defaults to my_activity. For other sorting options, see here.

OAuth

For API calls requiring permission, such as write operations or browsing friends, see our OAuth tutorial.

Testing

To run the test suite:

rake test

Contributions

You're welcome to submit patches and new features.

  • Create a new branch for your feature of bugfix
  • Add tests so it does not break any existing code
  • Open a new pull request
  • Check official API documentation

License

Copyright © 2011-2013 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.

goodreads's People

Contributors

sosedoff avatar pemulis avatar ivanoblomov avatar auxbuss avatar thegreatape avatar alexmuir avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.