> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# IInsightsQuery

- Package: [@gooddata/sdk-backend-spi](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/index.md)
- Kind: interface
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-backend-spi/src/workspace/insights/index.ts

Service to query insights.

**Signature:**

```typescript
export interface IInsightsQuery 
```

## Methods

| Method | Description |
| --- | --- |
| [query()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsqueryquery) | Starts the query. |
| [withFilter(filter)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithfilter) | Sets filter for the query. |
| [withInclude(include)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithinclude) | Sets include for the query. |
| [withMetaInclude(metaInclude)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithmetainclude) | Sets meta include for the query. |
| [withMethod(method)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithmethod) | **_(BETA)_** Selects which backend endpoint flavor to use when listing insights. Default method: "GET" |
| [withOrigin(origin)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithorigin) | Sets origin for the query. |
| [withPage(page)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithpage) | Sets starting page for the query. Backend WILL return no data if the page is greater than total number of pages. Default page: 0 |
| [withSize(size)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithsize) | Sets number of insights to return per page. Default size: 50 |
| [withSorting(sort)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md#iinsightsquerywithsorting) | Sets sorting for the query. |

## Method details

### IInsightsQuery.query()

Starts the query.

**Signature:**

```typescript
query(): Promise<IInsightsQueryResult>;
```
**Returns:**

Promise&lt;[IInsightsQueryResult](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsqueryresult/index.md)&gt;

promise of first page of the results

### IInsightsQuery.withFilter()

Sets filter for the query.

**Signature:**

```typescript
withFilter(filter: IFilterBaseOptions): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| filter | [IFilterBaseOptions](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ifilterbaseoptions/index.md) | filter to apply |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query

### IInsightsQuery.withInclude()

Sets include for the query.

**Signature:**

```typescript
withInclude(include: string[]): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| include | string[] | include to apply |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query

### IInsightsQuery.withMetaInclude()

Sets meta include for the query.

**Signature:**

```typescript
withMetaInclude(metaInclude: string[]): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metaInclude | string[] | meta include to apply |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query

### IInsightsQuery.withMethod()

> **Beta API.** Mostly stable, but details may change in a minor release, outside SemVer. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Selects which backend endpoint flavor to use when listing insights. Default method: "GET"

**Signature:**

```typescript
withMethod(method: QueryMethod): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| method | [QueryMethod](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.querymethod/index.md) | endpoint flavor to use ("GET" or "POST") |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query

### IInsightsQuery.withOrigin()

Sets origin for the query.

**Signature:**

```typescript
withOrigin(origin: ObjectOrigin | (string & {})): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| origin | ObjectOrigin \| (string &amp; {}) | origin to apply. This is an open string union to allow platform-specific origin values in addition to the built-in literals. |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query

### IInsightsQuery.withPage()

Sets starting page for the query. Backend WILL return no data if the page is greater than total number of pages. Default page: 0

**Signature:**

```typescript
withPage(page: number): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| page | number | zero indexed, must be non-negative |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query

### IInsightsQuery.withSize()

Sets number of insights to return per page. Default size: 50

**Signature:**

```typescript
withSize(size: number): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| size | number | desired max number of insights per page must be a positive number |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query

### IInsightsQuery.withSorting()

Sets sorting for the query.

**Signature:**

```typescript
withSorting(sort: string[]): IInsightsQuery;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| sort | string[] | Sorting criteria in the format: property,(asc\|desc). Default sort order is ascending. Multiple sort criteria are supported. |

**Returns:**

[IInsightsQuery](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iinsightsquery/index.md)

insights query
