# Getting Started

The Flipbook JavaScript API makes it easy to execute commands in flipbooks as well as listen/subscribe to events happening inside these. The JS API is available both for embedded flipbooks as well as directly in the flipbook viewer through custom scripting.&#x20;

Below are some guides to get you set up and ready to start exploring the possibilities of the JS API.

## Setting up the API for embedded Flipbooks

In order to use the JS API you must include the API script on your page. The API script can be seen below:

```html
<script src='https://cdn.ipaper.io/flipbooks/api/v3/latest.js'></script>
```

Once you have included this script on your page, you will need to instantiate a new instance of the API. When doing so you specify an iframe to target (your embedded flipbook) as well as an API version to use (version 3 is the latest and only version currently available):

```html
<script>
    const iframe = document.getElementById('myFlipbook');
    const instance = iPaperJsApi(iframe, 3);
</script>
```

Once this has been done, you're ready to start using the JS API. You can explore the [available commands and events here](https://docs.ipaper.io/flipbook-javascript-api/commands-and-events). You will be able to call/use these on the instance you set up above (i.e. `instance.[Category Name].[Command/Event name]`).

When using the JS API with embedded flipbooks, it is possible to have multiple flipbooks where each of them has their own API instance set up. [Please refer to this page on an example of this usage.](https://docs.ipaper.io/advanced-usage#multiple-embedded-flipbooks)

## Setting up the API in Custom Scripting

Using the JS API through the Flipbook Custom Scripting module is simple. The API script is already included in the flipbook viewer, so all you need to do is add a script that instantiates a new instance of the API. When doing so you will need to specify a version to use (version 3 is the latest and only version currently available):

<pre class="language-html"><code class="lang-html">&#x3C;script>
<strong>    const instance = iPaperJsApi(3);
</strong>&#x3C;/script>
</code></pre>

Once this has been done, you're ready to start using the JS API. You can explore the [available commands and events here](https://docs.ipaper.io/flipbook-javascript-api/commands-and-events). You will be able to call/use these on the instance you set up above (i.e. `instance.[Category Name].[Command/Event name]`).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ipaper.io/flipbook-javascript-api/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
