# DevTools In-page API

Canonical page: https://www.adaptabletools.com/docs/dev-guide-support-devtools-api

- `window.__ADAPTABLE_DEVTOOLS__` is defined as soon as AdapTable loads in the browser
- Consoles, tests and AI coding agents can read a live Grid without the Chrome extension
- Every method returns plain JSON unless noted

As soon as AdapTable loads in a browser it defines `window.__ADAPTABLE_DEVTOOLS__`.

- The [AdapTable DevTools](https://www.adaptabletools.com/docs/dev-guide-support-devtools/index.md) extension reads the same instance data
- This API does not require the extension

Call it from the browser console, a Playwright test, or an AI coding agent that can evaluate JavaScript in the page (Chrome DevTools MCP, the Cursor browser and similar).

Theme Builder, snapshot history and Migrate are part of the extension only

Every method returns plain JSON unless noted, so the result survives being copied out of the page.

- The `adaptableId` argument can be omitted when exactly one Grid is mounted
- With several Grids pass it, and the error message lists the mounted ids

```ts
window.__ADAPTABLE_DEVTOOLS__.listInstances();
window.__ADAPTABLE_DEVTOOLS__.getGridInfo('Trades');
window.__ADAPTABLE_DEVTOOLS__.getState('Trades', 'Layout');
window.__ADAPTABLE_DEVTOOLS__.getLogs('Trades', {level: ['error', 'warn']});
```

| Method                                       | Returns                                                                                                                                                                                                                                                                                                                                                      |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `help()`                                     | Usage text naming every method                                                                                                                                                                                                                                                                                                                               |
| `listInstances()`                            | Each mounted Grid: `adaptableId`, AdapTable and AG Grid versions, `adaptableStateKey`, `primaryKey`, `userName`, and `gridRuntime` (all / visible / selected row counts)                                                                                                                                                                                     |
| `getGridInfo(id?)`                           | What [Grid Info](https://www.adaptabletools.com/docs/ui-settings-panel-grid-info/index.md) shows: identity (including License Key and whether the Primary Key is auto-generated), current Layout (name, type, row groups, pivot columns, sorts), column filters, Grid Filter, row and column counts, Calculated / FreeText / Action Columns, available and unavailable Modules |
| `getState(id?, section?)`                    | The whole [Adaptable State](https://www.adaptabletools.com/docs/dev-guide-adaptable-state/index.md) (including the transient `Internal`, `Popup`, `Comment` and `Plugins` sections), or one section such as `'Layout'` or `'FormatColumn'`                                                                                                                                     |
| `getPersistentState(id?)`                    | The user state AdapTable persists; valid input for `restoreState` and for the [adaptable CLI](https://www.adaptabletools.com/docs/getting-started-ai-cli/index.md)'s `check state --kind persistent` and `migrate state` (and the `check_state` / `migrate_state` MCP tools)                                                                                                                                                    |
| `getColumns(id?)`                            | Columns with `id`, `friendlyName`, `dataType`, `field`, `columnTypes`, `visible` (per the current Layout), `readOnly`, `isPrimaryKey`, `isGrouped`, `pinned`, Calculated / FreeText / Action flags, and whether the column is a generated row-group or pivot-result column; the whole dump is the `--columns` input of `adaptable check state` (the `columns` input of the MCP tools)                    |
| `getColumnInfo(id?, columnId?)`              | Read-only [Column Info](https://www.adaptabletools.com/docs/ui-settings-panel-column-info/index.md) for one column: summary rows (id, header, data type, visibility, pinning, width, sort, filter, capability flags) and the objects scoped to it, using the same summary tags as the Settings Panel (including style colours). Omit `columnId` for the first column. `columns` lists every column so you can pick. Distinct cell values are not included |
| `getLogs(id?, { level?, channel?, limit? })` | Recent [log messages](https://www.adaptabletools.com/docs/dev-guide-support-logging/index.md) (default 100, newest last), buffered whether or not `localStorage.debug` is set; filter by level (`info`, `success`, `warn`, `error`, `perf`) or channel substring                                                                                                               |
| `getRecentActions(id?, limit?)`              | Recent state-changing actions (default 50, newest last)                                                                                                                                                                                                                                                                                                      |
| `restoreState(id?, state)`                   | `Promise`; loads a snapshot from `getState`, `getPersistentState` or a download from the extension; omit `id` when one Grid is mounted                                                                                                                                                                                                                       |
| `openSettingsPanel(id?, moduleName?)`        | Opens the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md), at a Module section when given                                                                                                                                                                                                                                                     |
| `setLogging(pattern)`                        | Writes `localStorage.debug` (e.g. `'Adaptable:Trades:*'`; `null` removes it) and returns the previous value; new channels pick it up at once, reload to apply it to every channel; see [Logging](https://www.adaptabletools.com/docs/dev-guide-support-logging/index.md)                                                                                                       |
| `enableProfiling(enabled?)`                  | Writes `localStorage.adaptableProfileTracks`; see [Profiling](https://www.adaptabletools.com/docs/dev-guide-support-profiling/index.md)                                                                                                                                                                                                                                        |
| `getApi(id?)`                                | The live `AdaptableApi` of the instance (not serialisable; for calls inside the page)                                                                                                                                                                                                                                                                        |

- Snapshots downloaded from the extension's **State** section are valid `restoreState` input
- They are also valid input for `adaptable check state --kind persistent` and `adaptable migrate state`

## AI Coding Agents

The [adaptable-debug](https://www.adaptabletools.com/docs/getting-started-ai-skills-debug/index.md) Agent Skill tells agents to read a running Grid through this API with whichever browser tool they have, instead of writing in-page scripts: `listInstances()`, `getGridInfo()` (with the licence key stripped), `getLogs()` for errors and warnings, `getRecentActions()`, `getColumns()` and only the implicated State section.

To add the Skill: `npx skills add https://www.adaptabletools.com`

The Skill then validates what it extracted with the [adaptable CLI](https://www.adaptabletools.com/docs/getting-started-ai-cli/index.md):

<AiCli args="check state persistent-state.json --columns columns.json --kind persistent" />

`persistent-state.json` is `getPersistentState()` and `columns.json` is `getColumns()`, saved to files. The same two files, with `getGridInfo()` and `getLogs()`, are the support bundle the Skill anonymises for a support case.

- The API is defined only in the browser and only once AdapTable's code has loaded
- A method that throws `no AdapTable instance is mounted yet` means the Grid is still initialising
