> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/ja-gitbook-documentation/gong-kai/embedding/configuration/reference.md).

# API リファレンス

Docs Embed は、統合方法に応じて異なるAPIを提供します。このリファレンスでは、各統合方法で利用可能なすべてのメソッドを扱います。

## メソッド比較

| 方法                | スタンドアロンスクリプト                                                 | NPMパッケージ                              | Reactコンポーネント                         |
| ----------------- | ------------------------------------------------------------ | ------------------------------------- | ------------------------------------ |
| **初期化**           | `GitBook('init', options, frameOptions)`                     | `createGitBook(options)`              | `<GitBookProvider siteURL="...">`    |
| **カラースキームの上書き**   | `GitBook('init', options, { colorScheme })`                  | `client.getFrameURL({ colorScheme })` | `<GitBookFrame colorScheme="..." />` |
| **フレームURLを取得**    | ❌（内部で処理）                                                     | `client.getFrameURL(options)`         | `useGitBook().getFrameURL(options)`  |
| **フレームクライアントを作成** | ❌（内部で処理）                                                     | `client.createFrame(iframe)`          | `useGitBook().createFrame(iframe)`   |
| **ウィジェットの表示/非表示** | `GitBook('show')` / `GitBook('hide')`                        | ❌                                     | ❌                                    |
| **ウィンドウを開く/閉じる**  | `GitBook('open')` / `GitBook('close')` / `GitBook('toggle')` | ❌                                     | ❌                                    |
| **ページへ移動**        | `GitBook('navigateToPage', path)`                            | `frame.navigateToPage(path)`          | フレームクライアント経由                         |
| **アシスタントへ移動**     | `GitBook('navigateToAssistant')`                             | `frame.navigateToAssistant()`         | フレームクライアント経由                         |
| **メッセージを投稿**      | `GitBook('postUserMessage', message)`                        | `frame.postUserMessage(message)`      | フレームクライアント経由                         |
| **チャットをクリア**      | `GitBook('clearChat')`                                       | `frame.clearChat()`                   | フレームクライアント経由                         |
| **設定**            | `GitBook('configure', settings)`                             | `frame.configure(settings)`           | のProps `<GitBookFrame>`              |
| **イベントリスナー**      | ❌                                                            | `frame.on(event, listener)`           | フレームクライアント経由                         |
| **アンロード**         | `GitBook('unload')`                                          | ❌                                     | ❌                                    |

## スタンドアロンスクリプトAPI

### 初期化

#### `GitBook('init', options, frameOptions)`

サイトURLと、必要に応じて認証済みアクセスを指定してウィジェットを初期化します。

**パラメータ:**

* `options`: `{ siteURL: string }` - あなたのGitBookドキュメントサイトのURL
* `frameOptions`: `{ visitor?: { token?: string, unsignedClaims?: Record<string, unknown> }, colorScheme?: 'light' | 'dark' }` （オプション）- フレームオプション

**例:**

```javascript
window.GitBook('init', 
  { siteURL: 'https://docs.company.com' },
  { visitor: { token: 'your-jwt-token' }, colorScheme: 'dark' }
);
```

省略した場合、 `colorScheme` iframeのCSSに従います `color-scheme`.

### ウィジェット制御

#### ウィジェットを表示

非表示になっている場合はGitBookウィジェットを表示します。

**例:**

```js
window.GitBook("show");
```

#### ウィジェットを非表示

GitBookウィジェットをアンロードせずに非表示にします。

**例:**

```js
window.GitBook("hide");
```

#### ウィンドウを開く

Docs Embedウィンドウを開きます。

**例:**

```js
window.GitBook("open");
```

#### ウィンドウを閉じる

Docs Embedウィンドウを閉じます。

**例:**

```js
window.GitBook("close");
```

#### ウィンドウを切り替える

Docs Embedウィンドウの開閉を切り替えます。

**例:**

```js
window.GitBook("toggle");
```

#### ウィジェットをアンロード

サイトからGitBookウィジェットを完全に削除します。

**例:**

```js
window.GitBook("unload");
```

### ナビゲーション

#### `GitBook('navigateToPage', path)`

パスでGitBookドキュメント内の特定のページへ移動します。

**パラメータ:**

* `path` (string): 移動先ページのパス

**例:**

```javascript
// はじめにガイドへ移動
window.GitBook("navigateToPage", "/getting-started");

// 特定のAPIドキュメントページへ移動
window.GitBook("navigateToPage", "/api/authentication");

// FAQセクションへ移動
window.GitBook("navigateToPage", "/faq/billing");
```

#### `GitBook('navigateToAssistant')`

アシスタントタブへ直接移動します。

**例:**

```javascript
// アシスタントタブに切り替え
window.GitBook("navigateToAssistant");

// ボタンクリックへの応答として使用できます
document.getElementById("help-button").addEventListener("click", () => {
  window.GitBook("navigateToAssistant");
});
```

### チャット

#### `GitBook('postUserMessage', message)`

ユーザーが入力したかのようにチャットへメッセージを投稿します。

**パラメータ:**

* `message` (string): チャットに投稿するメッセージ

**例:**

```javascript
// 定義済みメッセージを送信
window.GitBook("postUserMessage", "How do I reset my password?");

// ユーザーの操作に基づいてメッセージを送信
function askAboutBilling() {
  window.GitBook("postUserMessage", "I have questions about my billing");
}

// 文脈付きのメッセージを送信
const userPlan = "premium";
window.GitBook(
  "postUserMessage",
  `私は${userPlan}プランを利用していて、高度な機能について დახმარが必要です`
);
```

#### `GitBook('clearChat')`

現在のチャットセッションからすべてのメッセージを消去します。

**例:**

```javascript
// チャットをクリア
window.GitBook("clearChat");

// チャットをクリアして新しい会話を開始
function startNewConversation() {
  window.GitBook("clearChat");
  window.GitBook("postUserMessage", "Hello, I need help with a new issue");
}

// 文脈を切り替えるときにチャットをクリア
document.getElementById("new-topic").addEventListener("click", () => {
  window.GitBook("clearChat");
  window.GitBook("navigateToAssistant");
});
```

### 設定

#### `GitBook('configure', settings)`

カスタマイズオプションで埋め込みを設定します。  [設定セクション](/docs/documentation/ja-gitbook-documentation/gong-kai/embedding/implementation/script.md#configuration-options) で利用可能なオプションをご覧ください。

**例:**

```javascript
window.GitBook('configure', {
  trademark: false,
  tabs: ['assistant', 'search', 'docs'],
  actions: [
    {
      icon: 'circle-question',
      label: 'サポートに連絡',
      onClick: () => window.open('https://support.example.com', '_blank')
    }
  ],
  greeting: { title: 'ようこそ！', subtitle: 'どのようにお手伝いできますか？' },
  assistantName: 'Support Copilot',
  closeButton: true,
  suggestions: ['GitBookとは何ですか？', 'どのように始めればよいですか？']
});
```

## NPMパッケージAPI

### クライアントファクトリー

#### `createGitBook(options)`

GitBookクライアントインスタンスを作成します。

**パラメータ:**

* `options`: `{ siteURL: string }` - あなたのGitBookドキュメントサイトのURL

**戻り値:** `GitBookClient`

**例:**

```javascript
import { createGitBook } from '@gitbook/embed';

const gitbook = createGitBook({
  siteURL: 'https://docs.company.com'
});
```

#### `client.getFrameURL(options)`

必要に応じて認証済みアクセスを含めたiframe URLを取得します。

**パラメータ:**

* `options`: `{ visitor?: { token?: string, unsignedClaims?: Record<string, unknown> }, colorScheme?: 'light' | 'dark' }` （オプション）

**戻り値:** `string`

**例:**

```javascript
const iframeURL = gitbook.getFrameURL({
  colorScheme: 'dark',
  visitor: {
    token: 'your-jwt-token',
    unsignedClaims: { userId: '123', plan: 'premium' }
  }
});
```

#### `client.createFrame(iframe)`

iframeと通信するフレームクライアントを作成します。

**パラメータ:**

* `iframe`: `HTMLIFrameElement` - iframe要素

**戻り値:** `GitBookFrameClient`

**例:**

```javascript
const iframe = document.createElement('iframe');
iframe.src = gitbook.getFrameURL();
const frame = gitbook.createFrame(iframe);
```

### フレームクライアントのメソッド

#### `frame.navigateToPage(path)`

docsタブ内の特定ページへ移動します。

**パラメータ:**

* `path`: `string` - ページのパス

#### `frame.navigateToAssistant()`

アシスタントタブに切り替えます。

#### `frame.postUserMessage(message)`

チャットにメッセージを投稿します。

**パラメータ:**

* `message`: `string` - 投稿するメッセージ

#### `frame.clearChat()`

チャット履歴を消去します。

#### `frame.configure(settings)`

埋め込みを設定します。  [設定セクション](/docs/documentation/ja-gitbook-documentation/gong-kai/embedding/implementation/nodejs.md#configuration-options) で利用可能なオプションをご覧ください。

#### `frame.on(event, listener)`

イベントリスナーを登録します。

**パラメータ:**

* `event`: `string` - イベント名
* `listener`: `関数` - コールバック関数

**戻り値:** `() => void` - 解除関数

**例:**

```javascript
const unsubscribe = frame.on('close', () => {
  console.log('Frame closed');
});

// 後で解除
unsubscribe();
```

## ReactコンポーネントAPI

を参照してください。 [React統合ガイド](/docs/documentation/ja-gitbook-documentation/gong-kai/embedding/implementation/react.md) コンポーネントのpropsと `useGitBook` フックAPIについて。

`GitBookFrame` がサポートする `assistantName`, `closeButton`, `colorScheme="light" | "dark"`、および `visitor` 認証済みアクセス用のprop。

`useGitBook().getFrameURL()` は同じ `colorScheme` パラメータをNPMパッケージと同様に受け取ります。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/gong-kai/embedding/configuration/reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
