> For the complete documentation index, see [llms.txt](https://developer.eagle.cool/web-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.eagle.cool/web-api/ja-jp/api/library.md).

# Library

Library API を使用すると、現在開いている Eagle ライブラリの情報を取得できます。

## エンドポイント一覧

| メソッド | エンドポイント                   | 説明             |
| ---- | ------------------------- | -------------- |
| GET  | `/api/v2/library/info`    | ライブラリのメタデータを取得 |
| GET  | `/api/v2/library/history` | ライブラリ履歴リストを取得  |
| POST | `/api/v2/library/switch`  | 指定のライブラリに切り替え  |
| GET  | `/api/v2/library/icon`    | ライブラリのアイコンを取得  |

***

## GET /api/v2/library/info <a href="#info" id="info"></a>

現在開いている Eagle ライブラリのメタデータ（名前、パス、設定など）を返します。

### レスポンス

```json
{
    "status": "success",
    "data": {
        "name": "My Design Library",
        "path": "D:\\Eagle Libraries\\My Design Library.library",
        "modificationTime": 1700000000000,
        "applicationVersion": "4.0",
        "folders": [],
        "smartFolders": [],
        "quickAccess": [],
        "tagGroups": []
    }
}
```

### 例

```javascript
await fetch("http://localhost:41595/api/v2/library/info").then(r => r.json());
```

***

## GET /api/v2/library/history <a href="#history" id="history"></a>

ライブラリの履歴リストを取得します。ページネーションされた結果を返します。

### クエリパラメータ

* `offset` integer（任意）-- ページネーションオフセット、デフォルト `0`
* `limit` integer（任意）-- ページネーションリミット、デフォルト `50`、最大 `1000`

### レスポンス

```json
{
    "status": "success",
    "data": {
        "data": [
            {
                "name": "My Design Library",
                "path": "D:\\Eagle Libraries\\My Design Library.library"
            }
        ],
        "total": 3,
        "offset": 0,
        "limit": 50
    }
}
```

### 例

```javascript
await fetch("http://localhost:41595/api/v2/library/history").then(r => r.json());

// ページネーション付き
await fetch("http://localhost:41595/api/v2/library/history?offset=0&limit=10").then(r => r.json());
```

***

## POST /api/v2/library/switch <a href="#switch" id="switch"></a>

指定のライブラリに切り替えます。

### リクエストボディ

* `libraryPath` string（必須）-- 切り替え先のライブラリパス

### レスポンス

```json
{
    "status": "success",
    "data": true
}
```

### 例

```javascript
await fetch("http://localhost:41595/api/v2/library/switch", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        libraryPath: "D:\\Eagle Libraries\\My Design Library.library"
    })
}).then(r => r.json());
```

***

## GET /api/v2/library/icon <a href="#icon" id="icon"></a>

ライブラリのアイコンを取得します。

### クエリパラメータ

* `libraryPath` string（必須）-- ライブラリのパス

### レスポンス

アイコンの画像データを返します。

### 例

```javascript
await fetch("http://localhost:41595/api/v2/library/icon?libraryPath=D%3A%5CEagle%20Libraries%5CMy%20Design%20Library.library")
    .then(r => r.blob());
```

***

## ライブラリのプロパティ <a href="#properties" id="properties"></a>

ライブラリオブジェクトには以下のプロパティが含まれます：

| プロパティ                | 型         | 説明                        |
| -------------------- | --------- | ------------------------- |
| `name`               | string    | ライブラリの表示名                 |
| `path`               | string    | `.library` ディレクトリへのフルパス   |
| `modificationTime`   | integer   | 最終変更タイムスタンプ               |
| `applicationVersion` | string    | このライブラリを作成した Eagle のバージョン |
| `folders`            | Object\[] | トップレベルのフォルダ構造             |
| `smartFolders`       | Object\[] | スマートフォルダの設定               |
| `quickAccess`        | Object\[] | クイックアクセスのアイテム             |
| `tagGroups`          | Object\[] | タググループの定義                 |
