Goodreads Views Submodule

Last updated on
30 April 2025

This submodule implements a common use case of Goodreads data integration using Views. Once a day during a cron job, the books on every shelf for every Drupal user that has a corresponding Goodreads user ID is read into a MySQL table in Drupal.

The Goodreads views submodule currently uses the Goodreads OAuth submodule primarily as its way of knowing that Goodreads user ID is associated with each Drupal UID. In addition it uses the OAuth version of the Goodreads get the books on a user’s shelf API call to access a complete listing of books on all shelves, overriding the visibility settings that might hide bookshelves depending on how the user has set their Goodreads privacy options. It would be relatively straightforward to create a non-OAuth alternative.

To use the Goodreads views submodule

  1. Make sure you have the main Goodreads module installed and configured, as well as the Goodreads OAuth submodule, along with the Views module, and any of its required modules, and the Drupal Queue module.
  2. Enable the Goodreads views submodule on your site’s module page (Administer > Site building > Modules).
  3. Configure the maximum number of books and when to start the cron update at the Goodreads views settings page (Administer > Site configuration > Goodreads API > Views). Some Goodreads users can have a large number of books, organized on a large number of shelves. For many applications, the performance overhead of downloading hundreds, or thousands, of books for many bookshelves isn’t desirable. The number per bookshelf can be limited using the first setting. The Goodreads views submodule updates its table once a day, using the Drupal Queue module’s queuing to avoid cron timeouts. You can select what time of day to schedule the Goodreads views cron job using a pull down selection. Your cron should be set up to run often enough to allow the Drupal Queue module to process all the Goodreads views jobs scheduled each day. As a rule of thumb, depending on how many books each user has, approximately 5-10 users are processed per cron run. Depending on how many users you have for Goodreads views, you may need to configure the Drupal Queue module’s separate cron job option to be processed much more frequently than your site’s regular cron job.

Goodreads views module settings page

From the Goodreads views submodule configuration page you can force the scheduling of a Goodreads views cache refill, which still requires the how ever many cron runs necessary to process the users, or clear the data in the Goodreads views cache table, which deletes all the Goodreads views data.

Once the cron run has populated the Goodreads views data table, the following fields are available to views:

  • User ID from {user}.uid.
  • Cache time, the date and time the cache data was created.
  • Goodreads user ID
  • Shelf name, the Goodreads shelf this book is on.
  • Title, the title of book.
  • Author, the primary author of the book.
  • Ratings count, the number of ratings for this book.
  • Average rating, the average rating for this book.
  • Text reviews count, the number of text reviews. (reviews with more than the five star rating)
  • Image URL, the URL of a book image. Note that a high percentage of the book images shown on the Goodreads site are restricted from distribution via the API. You may find you need the Amazon module to display book images or use LibraryThing's database of book covers.
  • ISBN, the ISBN for the book.
  • Goodreads book ID.
  • Description, the description of the book.

The table is defined as a base table, which means you can create a view type of Goodreads Book Data, which is listed at the bottom of the add view page.

The table is also related to Drupal's User type, allowing relationships from either a User view type to Goodreads book data, or from a Goodreads book data view type to user fields. The relationship is selected by adding a relationship from views third column, Relationships, and selecting Goodreads Book Data: Drupal User ID.

Help improve this page

Page status: Not set

You can: