# QueryBuilderApi (@salmonui/query-builder)

> The QueryBuilderApi interface of @salmonui/query-builder.

Canonical: https://salmonui.dev/docs/reference/query-builder/QueryBuilderApi

```ts
import type { QueryBuilderApi } from '@salmonui/query-builder';
```

Entry index: https://salmonui.dev/docs/reference/query-builder (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/query-builder.md).

## Reference

Kind: interface

```ts
interface QueryBuilderApi {
    getValue(): QueryGroup;
    setValue(value: QueryGroup): void;
    getValidValue(): QueryGroup;
    getNode(id: string): QueryNode | null;
    addRules(rules: readonly QueryRule[], groupId?: string): string[];
    addGroups(groups: readonly QueryGroup[], groupId?: string): string[];
    remove(ids: string | readonly string[]): void;
    clone(id: string, options?: {
        readonly parentId?: string;
        readonly index?: number;
    }): string | null;
    lock(id: string, locked?: boolean): void;
    validate(): boolean;
    reset(): void;
    focus(): void;
}
```

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `getValue` | `getValue(): QueryGroup;` |  |  |
| `setValue` | `setValue(value: QueryGroup): void;` |  |  |
| `getValidValue` | `getValidValue(): QueryGroup;` |  | The value without incomplete rules and empty groups. |
| `getNode` | `getNode(id: string): QueryNode \| null;` |  |  |
| `addRules` | `addRules(rules: readonly QueryRule[], groupId?: string): string[];` |  | Appends rules to the group `groupId` (default: the root); returns their ids. |
| `addGroups` | `addGroups(groups: readonly QueryGroup[], groupId?: string): string[];` |  |  |
| `remove` | `remove(ids: string \| readonly string[]): void;` |  |  |
| `clone` | `clone(id: string, options?: {     readonly parentId?: string;     readonly index?: number; }): string \| null;` |  | Copies a node next to itself (or into `parentId` at `index`); returns the copy's id. |
| `lock` | `lock(id: string, locked?: boolean): void;` |  |  |
| `validate` | `validate(): boolean;` |  | Validates every rule, shows inline errors and returns whether the value is valid. |
| `reset` | `reset(): void;` |  | Back to `defaultValue` (uncontrolled) or proposes it (controlled). |
| `focus` | `focus(): void;` |  | Moves focus to the first control. |
