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


---

# 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://developer.eagle.cool/web-api/api/library.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.
