> 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/api/library.md).

# Library

## Endpoints Overview

| Method | Endpoint                  | Description              |
| ------ | ------------------------- | ------------------------ |
| GET    | `/api/v2/library/info`    | Get library metadata     |
| GET    | `/api/v2/library/history` | Get library history list |
| POST   | `/api/v2/library/switch`  | Switch to a library      |
| GET    | `/api/v2/library/icon`    | Get library icon         |

***

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

Returns metadata about the currently open Eagle library, including its name, path, and configuration.

### Response

```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": []
    }
}
```

### Example

```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>

Get the list of recently opened libraries. Returns paginated results.

### Query Parameters

* `offset` integer (optional) — Pagination offset, default `0`
* `limit` integer (optional) — Pagination limit, default `50`, max `1000`

### Response

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

### Examples

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

// With pagination
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>

Switch to a specified library.

### Request Body

* `libraryPath` string (required) — Path to the library to switch to

### Response

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

### Example

```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>

Get the icon for a library.

### Query Parameters

* `libraryPath` string (required) — Path to the library

### Response

Returns the icon image data.

### Example

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

***

## Library Properties <a href="#properties" id="properties"></a>

The library object contains the following properties:

| Property             | Type      | Description                             |
| -------------------- | --------- | --------------------------------------- |
| `name`               | string    | Library display name                    |
| `path`               | string    | Full path to the `.library` directory   |
| `modificationTime`   | integer   | Last modification timestamp             |
| `applicationVersion` | string    | Eagle version that created this library |
| `folders`            | Object\[] | Top-level folder structure              |
| `smartFolders`       | Object\[] | Smart folder configurations             |
| `quickAccess`        | Object\[] | Quick access items                      |
| `tagGroups`          | Object\[] | Tag group definitions                   |
