Google Books Module and API Usage
Google Books Module
Author: Darrell Ulm
The Google Books module is a filter and a Google Books API that allows a user to insert rich Google book data into nodes via filters.
The user of this filter module will be able to easily insert:
- book data from Google into pages using Drupal filters,
- a book cover image when it exists,
- there are options to include / exclude any data fields,
- and for books with a full or partial preview, the Google book reader for the volume.
- To create a content type that uses Google Books, a text field can be used with an text-format with Google Books enabled as a filter, see issue: https://www.drupal.org/node/2094187.
The starting framework of the code was based on the Book Post module to get ideas which gets data from Open Library instead of the Google Books API although little remains of that module other than the framework. The Google Books module API is different based on the data returned as well as the final aims of the module, although they do both return book data.
The Google Book search can be done with many types of search strings.
There are many search options with Google books and many options to display that data within the Google Book module. The API pulls data from Google Books in a generic way.
Installation
Google Book Module installation instructions:
- Copy the "google_books" directory into a Drupal modules directory, like sites/all/modules.
- Enable module at: Administer->Site Building->Modules->Google_Books
- Turn on input filter at: Administer->Site Configuration->Input Formats. Open any input filter (for example, Filtered HTML) and check box for the Google Book Filter.
Requirements / Dependencies
Drupal 7: No dependencies, it should just install.
Configuration
- Once you turn the filter on with the radio button at config/content/formats, put it in the order where the
output is where you need it. That is, don't put it before a "filter out all HTML" filter if you want anything to display.
the order until you are happy with it. - Select the options for the information you want to display for your volume.
You can display many fields, and some you will, no doubt, want to turn off. - To test, go create a page or article, and then just place your
Google Books search string inside [google_books: ] square brackets with the google_books: prefix on the filter tag. Google book allows many types of searching including full text,
author, and even inside text. ISBNs and other standard identifiers
work also. The Google Books API is very flexible. - After you save your node, if the filter was installed correctly you should
see your book information with the data you selected. If your selected data
is not visible for a volume, then it was not in the data returned from
Google. - See http://books.google.com/advanced_book_search to find some good ways
of handling your search. Once you find a search you like, then just copy the
string between the braces [google_books: ]. - Also see: http://code.google.com/apis/books/docs/v1/using.html#PerformingSearch for specifics on performing a search.
GOOGLE API KEY for many requests per day
IMPORTANT NOTE: make sure the correct API key is applied specifically for Google Book data or the log will show errors and no books will appear while an incorrect API Key is in this field. Removing an incorrect key should resume normal book loads up to the default, unregistered limit, like 100 instead of 1000.
If your application will need many requests, your site will need to have a registered key from google as there appears to be an API limit (with a valid key) per day. The API Key can be created setup at:
https://code.google.com/apis/console
- Need to create a key for the Books API
- then click on Quotas and will see:
- Courtesy Limit
Per-User Limit: 1.0 requests/second/user Used: 0% Courtesy Limit: 1,000 requests/day Link: Request more... Link: Set per-user limits...
If the per user limit "Request More" link is clicked, a new form to request more usage reads:
"Description: Please provide a description of your API usage."
Original issue reference: https://www.drupal.org/node/1925058
Google Book data shown in Content text fields
If you want to create your own content type with Google Book data, it can work with a text field with the text-format set to include Google Books. The [] brackets still need to be included with all the other filter parameters - although simple [google_books:book-title] or [google_books:isbn] tags are the easiest. For more information see: See Issue: https://www.drupal.org/node/2094187.
[google_books:Andriod Game Development] [google_books:google_books:A Philosophical and Mathematical Dictionary Containing|no_reader| pageCount | no_categories]
Basic Example
Possible search strings to pull data from Google Books. Currently this module will only pull the general volume information up for the filter. When the API is added then it is intended to make this more generic to return multiple specific volumes.
[google_books: drupal+7+development]
[google_books:isbn:1556508093]
[google_books:tolkien+encyclopedia]
[google_books:soccer+football+europe]
[google_books:great expectations]
How to use the inline options
In line display options to override the global Google Book filter settings can be made by options after the search string. The format for the search strings and options are:
Use global display options:
[google_books:search string]
In line options always come after the search string and are separated by a vertical bar, i.e. a '|' character.
[google_books: search string | option 1 | option 2 | option 3 | ... ]
Options to include are just used normally, like 'worldcat' while options to exclude in the display are prefaced by the 'no_' prefix.
Example:
[google_books: The Hobbit | no_librarything | no_image | viewer | title | no_description]
These are the content options:
- worldcat / no_worldcat
- openlibrary / no_openlibrary
- librarything / no_librarything
- pagecurl / no_pagecurl
- titlelink / no_titlelink
- image / no_image
- reader / no_reader
Also each an every data field can be turned on or off overriding the Google Books filter global default.
The in_line field settings are below
- kind
- id
- etag
- selfLink
- volumeInfo
- title
- authors
- publisher
- publishedDate
- description
- industryIdentifiers
- type
- identifier
- pageCount
- dimensions
- height
- width
- thickness
- printType
- mainCategory
- categories
- averageRating
- ratingsCount
- contentVersion
- imageLinks
- smallThumbnail
- thumbnail
- small
- medium
- large
- extraLarge
- language
- previewLink
- infoLink
- canonicalVolumeLink
- saleInfo
- country
- saleability
- isEbook
- listPrice
- amount
- currencyCode
- buyLink
- accessInfo
- viewability
- embeddable
- publicDomain
- textToSpeechPermission
- epub
- acsTokenLink
- accessViewStatus
Theming and Output
There are plenty of CSS classes embedded to enable theming. In fact there is one for each field based on the field name for very specific book data theming.
No Drupal 6 Support for Google Books
Drupal 7 and Drupal 9 currently supported.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion