(No longer available)
(No longer available)
The Google Books Dynamic Links feature allows you to create more customizable, reliable links to Google Books from your site. For example, this tool lets you generate "smart" links that appear only when a book is in our index, or display links that indicate to your users whether a book can be previewed on Google Books. The Dynamic Links feature also lets you include a thumbnail image in your link to Google Books. This document is intended to let you quickly add this functionality to your site.
Note: This feature was formerly known as the the Book Viewability API.
The Preview Wizard is a tool built atop Dynamic Links that makes it even easier to link to book previews from site by just copying a few lines of code. This document is intended for more advanced developers looking to customize how they link to Book Search.
The dynamic links documentation is intended for programmers who want to write web applications that link to books within Google Books. This documentation assumes that you are familiar with the HTTP protocol and basic JavaScript.
Google Books respects the user's local copyright restrictions, and as a result, previews or full views of some books are not available in all locations. Viewability is clustered into the following classes:
The Static Links documentation describes a very simple way of generating URLs to a particular book's page on Google Books. Unfortunately, it is sometimes the case that a particular book is not in the Google Books index, or that a preview is not available to a user in a particular geographic location. Because Static Links are "blind," they sometimes fail to have the intended effect.
Dynamic Links provides an alternative, programmatic client-side method for querying the viewability of a book using JavaScript. This allows you to include more reliable and predictable links to Book Search, leading to a more consistent experience for your users. Because viewability varies according to the end user's location, the dynamic link interface is not designed for server-side or offline queries.
To get a sense of what Dynamic Links can do, skip to the code samples at the end of this document.
When rendering Dynamic Links, you must abide by the branding guidelines that govern the Google Books API Family. In particular,
The samples section at the end of this document provides additional examples that are compliant with the current branding guidelines.
At the core of the client-side dynamic link is a URL format that allows developers to construct URLs requesting information on one or more books and send the requests to Google Books using the <script> tag.
<script src="http://books.google.com/books?bibkeys=ISBN:0451526538&jscmd=viewapi&callback=mycallback"></script>The format of the URL is similar to the URL syntax used to link to books, but the book ID field may contain multiple comma separated book IDs and there are additional 'jscmd' and 'callback' parameters. Optionally, additional arguments can be present to control the viewability filters.
Dynamic Links supports several different methods for identifying books: ISBNs, OCLC numbers, and LCCN keys. The API allows batched queries of up to the size of the max size of a GET request.
&bibkeys=ISBN:0451526538 (The API supports both ISBN 10 and 13.)&bibkeys=OCLC:36792831&bibkeys=LCCN:96072233The response from this call will be information about the requested books returned as one or more JSON objects. The JSON objects use the following structure:
JsonSearchResult {
string bib_key;
string info_url;
string preview_url;
string thumbnail_url;
string preview;
};
These fields provide the following information:
full (for Full View books), partial (for Limited Preview books), or noview (for Snippet or No Preview books).true if the book can be embedded onto third party pages using the Book Search embedded viewer.The response is a JSON object with two fields, "books" which has a value of a map of book objects and "options" which contains a list of the options enabled for that request. If no options were specified, the "options" field may be omitted in the response. For example:
Request:
http://books.google.com/books?jscmd=viewapi&bibkeys=0596000278,00-invalid-isbn,ISBN0765304368,0439554934&callback=ProcessGBSBookInfo
Response:
ProcessGBSBookInfo({
"0596000278":{
"bib_key":"0596000278",
"info_url":"http://books.google.com/books?id=ezqe1hh91q4C&source=gbs_ViewAPI",
"preview_url":"http://books.google.com/books?id=ezqe1hh91q4C&printsec=frontcover&sig=zSQ5gwlX1NZl_24M86KS8Rbj33Q&source=gbs_ViewAPI",
"thumbnail_url":"http://books.google.com/books?id=ezqe1hh91q4C&pg=PR3&img=1&zoom=5&sig=bBmzIAIiCtMcM7Ii7TUHycqqEWg",
"preview":"partial"
},
"ISBN0765304368":{
"bib_key":"ISBN0765304368",
"info_url":"http://books.google.com/books?id=gfg13CM_kU8C&source=gbs_ViewAPI",
"preview_url":"http://books.google.com/books?id=gfg13CM_kU8C&printsec=frontcover&sig=jIrSb_SkcQRhy_VvtnKbTXjmvos&source=gbs_ViewAPI",
"thumbnail_url":"http://books.google.com/books?id=gfg13CM_kU8C&pg=PP1&img=1&zoom=5&sig=LsTwGVAsy_qWYMPM6HVDTPAMokg",
"preview":"full"
},
"0439554934":{
"bib_key":"0439554934",
"info_url":"http://books.google.com/books?id=iwiYGwAACAAJ&source=gbs_ViewAPI",
"preview_url":"http://books.google.com/books?id=iwiYGwAACAAJ&source=gbs_ViewAPI",
"thumbnail_url":"http://books.google.com/books?id=iwiYGwAACAAJ&printsec=frontcover&img=1&zoom=5&sig=_L6ySKDAs-8gNK28c3NyFdO22ZM",
"preview":"noview"}
});
Developers may then change the content and appearance of their web pages based on the JSON results retrieved from the GBS server. At this time, GBS does not provide libraries for modifying the DOM to do this.
In Asynchronous Mode, the developer places the <script> tag in the <head> of the document and constructs the URL with all the identifiers that are needed for rendering the page. The data is received from the call in a variable. This makes the book's information available to the rest of the document and it can be accessed immediately in the HTML and JavaScript.
In Synchronous mode, the developer uses the URL in the middle of the HTML <body>; the response is handled using a JavaScript callback.
This section provides samples that illustrate different ways of using Dynamic Links. You can click any example to see it in action. To see the underlying code, "view source" from your browser.