# Reference

The Embedded Viewer API contains one class: DefaultViewer. For an introduction to using the API, see the [Developer's Guide](https://developers.google.com/books/docs/viewer/developers_guide).

## Constructor summary

`
[google.books.DefaultViewer](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer)(div, opt_options)
`
:   An embedded viewer for a volume in Google Book Search.

## Method summary

`string
[getPageNumber](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.getPageNumber)() `
:   Returns the page number of the page that's currently visible in
    the viewport.

`string
[getPageId](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.getPageId)() `
:   Returns a unique identifier for the page that's currently visible in the
    viewport.

`boolean
[goToPage](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.goToPage)(pageNumber) `
:   Returns true if the page exists and was turned to.

`boolean
[goToPageId](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.goToPageId)(pageId) `
:   Returns true if the page exists and was turned to.

`boolean
[isLoaded](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.isLoaded)()`
:   Indicates whether the viewer has been successfully initialized with the given book.

`
[highlight](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.highlight)(opt_string) `
:   Highlights a term in the viewport.

`
[load](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.load)(identifiers, opt_notFoundCallback, opt_successCallback) `
:   Loads a book in the viewport.

`
[nextPage](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.nextPage)() `
:   Goes to the next page in the book.

`
[previousPage](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.previousPage)() `
:   Goes to the previous page in the book.

`
[resize](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.resize)() `
:   Resizes the viewer to conform to size of its container div.

`
[zoomIn](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.zoomIn)() `
:   Zooms into the viewer.

`
[zoomOut](https://developers.google.com/books/docs/viewer/reference#google.books.DefaultViewer.zoomOut)() `
:   Zooms out of the viewer.

## Constructor detail

### google.books.DefaultViewer

```
google.books.DefaultViewer(div, opt_options)
```

An embedded viewer for a volume in Google Book Search.

<!-- -->

**Parameters:** `*Element* div` - Div to draw the viewport in.
<!-- -->

`*Object* opt_options` - Key-value map of options to pass along to the viewer.

## Method detail

### getPageNumber

```
string getPageNumber()
```

Returns the page number of the page that's currently visible in the viewport.

<!-- -->

**Returns:** `*string* `

### getPageId

```
string getPageId()
```

Returns a unique identifier for the page that's currently visible in the viewport.

<!-- -->

**Returns:** `*string* `

### goToPage

```
boolean goToPage(pageNumber)
```

Returns true if the page exists and was turned to.

<!-- -->

**Parameters:** `*string, number* pageNumber ` - The page number of the page to turn to.

<!-- -->

**Returns:** `*boolean* `

### goToPageId

```
boolean goToPageId(pageId)
```

Returns true if the page exists and was turned to.

<!-- -->

**Parameters:** `*string* pageId ` - The unique identifier of the page to turn to.

<!-- -->

**Returns:** `*boolean* `

### isLoaded

```
boolean isLoaded()
```

Returns true if the viewer has been successfully initialized with the given book using `load`.

<!-- -->

**Returns:** `*boolean* `

### highlight

```
highlight(opt_string)
```

Highlights a term in the viewport.

<!-- -->

**Parameters:** `*string* opt_string ` - A string to highlight. Turns off highlighting if `null` or `undefined`.

### load

```
load(identifiers, opt_notFoundCallback, opt_successCallback)
```

Loads a book in the viewport.

<!-- -->

**Parameters:** `*string*, *Array of strings* identifiers ` - A preview URL or book identifier such as an ISBN, OCLC, etc. See [Dynamic Links request format](https://developers.google.com/books/docs/dynamic-links#requestFormat). To specify several alternative identifiers for the book (e.g., the hardcover and softcover ISBNs), pass an `Array` of these identifier strings; the viewer will the viewer will load the first embeddable book in the array.
<!-- -->

`*Function* opt_notFoundCallback ` - If `identifier` is a book identifier, this callback will be called if the book was not found. If `null` passed or this parameter is omitted, no function will be called on failure.
<!-- -->

`*Function* opt_successCallback ` - This callback will be executed if and when the viewer is successfully instantiated with a particular book, and ready to receive function calls such as `nextPage`.

### nextPage

```
nextPage()
```

Goes to the next page in the book.

### previousPage

```
previousPage()
```

Goes to the previous page in the book.

### resize

```
resize()
```

Resizes the viewer to conform to size of its container div.

### zoomIn

```
zoomIn()
```

Zooms into the viewer.

### zoomOut

```
zoomOut()
```

Zooms out of the viewer.

[Back to top](https://developers.google.com/books/docs/viewer/reference#top)