# Examples and Demos

All of the examples contained within the Embedded Viewer API documentation set are listed below for quick reference. In addition, a number of additional demos are included to illustrate advanced concepts.

## Examples from the Developer's Guide

These basic examples appear in the [Developer's Guide](https://developers.google.com/books/docs/viewer/developers_guide) and cover the most common uses of the Embedded Viewer API.

- [book-simple](https://developers.google.com/books/docs/viewer/examples/book-simple)  
  The "Hello, World" example of the Embedded Viewer API, this example indicates how to load the API and draw a viewer with a particular book.
- [book-language](https://developers.google.com/books/docs/viewer/examples/book-language)  
  This example shows how to change the viewer's interface language, in this case to Brazilian Portuguese.
- [book-notfound](https://developers.google.com/books/docs/viewer/examples/book-notfound)  
  This shows how to add a callback function which is called when the viewer could not load the specified book. You can build on this example to gracefully handle such conditions.
- [book-success](https://developers.google.com/books/docs/viewer/examples/book-success)  
  This shows how to add a callback function which is called when the viewer has successfully initialized with a book and is ready to be manipulated programatically.
- [book-animate](https://developers.google.com/books/docs/viewer/examples/book-animate)  
  To illustrate how the viewer can be controlled programmatically using JavaScript, a preview is shown which automatically flips to the next page every 3 seconds.

## Programmatic control of the viewer

The viewer allows you to do with code almost anything the user can do by interacting with the the viewer. The examples below show how this might be useful.

- [book-interactions-controls](https://developers.google.com/books/docs/viewer/examples/book-interactions-controls)  
  This working example enumerates all the interaction methods supported by the viewer, including zoom, nextPage, goToPage, and highlighting functions.
- [book-interactions-openatpage](https://developers.google.com/books/docs/viewer/examples/book-interactions-openatpage)  
  Shows how to automatically open a book viewer on a particular page, using callbacks and the goToPage function.

## Combining with the Books API and Dynamic Links

When building advanced applications, you may find it useful to combine
the Embedded Viewer API with either the [Books API](https://developers.google.com/books/docs/v1/getting_started) or the
[Dynamic Links](https://developers.google.com/books/docs/dynamic-links)
feature. For example, it may be useful to know in advance whether a particular
preview will be available for embedding (e.g., to determine whether to give the
user the option to open a preview window on your site). Or, you may not know the
identifier for a particular book, and want to first "look it up" using the Books
API. The examples below indicate how to perform these operations.

- [book-dynamiclinks-zippy](https://developers.google.com/books/docs/viewer/examples/book-dynamiclinks-zippy)  
  Here we check whether a book is available for embedding first. If and only if it is available, we render a "preview zippy," which, when clicked, shows the book preview inline.
- [booksapi-titlesearch](https://developers.google.com/books/docs/viewer/examples/booksapi-titlesearch)  
  This example allows you open an embedded viewer by simply entering a search query for a book. It will automatically show the first embeddable result for the query you enter. This uses the JSON output format of the Data API to access the search results.