---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.com/dev/webmaster/doc/en/reference/host-search-queries-history.md
  - https://yandex.com/dev/webmaster/doc/ru/reference/host-search-queries-history.md
keywords:
  - s
  - i
  - t
  - e
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/webmaster/doc/en/llms.txt


# Getting general statistics for a search query

Allows you to get the history of changes in indicators for a search query for a period of time.

## Request format

```
GET https://api.webmaster.yandex.net/v4/user/{[user-id](*user-id)}/hosts/{[host-id](*host-id)}/search-queries/{[query-id](*query-id)}/history
  ? [[query_indicator](*query_indicator)=<string>]
  & [[device_type_indicator](*device_type_indicator)=<string>]
  & [[date_from](*date_from)=<datetime>]
  & [[date_to](*date_to)=<datetime>]
```



#|
||
`user-id`
|
<!-- source: en/_includes/popups.md -->
Type: `int64`. User ID. Required when calling all Yandex.Webmaster API resources. To get it, use the [GET /v4/user](https://yandex.com/dev/webmaster/doc/en/reference/user.md) method.
<!-- endsource: en/_includes/popups.md -->
||
||
`host-id`
|
<!-- source: en/_includes/popups.md -->
Type: `host id (string)`. The site ID. To get it, use the [GET /v4/user/{user-id}/hosts](https://yandex.com/dev/webmaster/doc/en/reference/hosts.md) method.
<!-- endsource: en/_includes/popups.md -->
||
||
`query-id`
|
<!-- source: en/_includes/popups.md -->
Type: `string`. Search query ID. To get it, use the [GET /v4/user/{user-id}/hosts/{host-id}/search-queries/popular](https://yandex.com/dev/webmaster/doc/en/reference/host-search-queries-popular.md) method.
<!-- endsource: en/_includes/popups.md -->
||
||
`query_indicator`
|
Indicators for displaying requests ([ApiQueryIndicator](*ApiQueryIndicator)). You can specify multiple indicators. For example, `query_indicator=TOTAL_SHOWS&query_indicator=TOTAL_CLICKS`.
||
||
`device_type_indicator`
|
Device type ([ApiDeviceTypeIndicator](*ApiDeviceTypeIndicator)). Default value: `ALL`.
||
||
`date_from`
|
<!-- source: en/_includes/popups.md -->
The start date of the range. If omitted, data is returned for the last week.
<!-- endsource: en/_includes/popups.md -->
||
||
`date_to`
|
<!-- source: en/_includes/popups.md -->
The end date of the range. If omitted, data is returned for the last week.
<!-- endsource: en/_includes/popups.md -->
||
|#

<!-- source: en/_includes/reference/api-query-indicator.md -->
### Query indicators (ApiQueryIndicator) {#api-query-indicator}

#|
|| **Indicator** | **Description** ||
|| `TOTAL_SHOWS` | The number of displays. ||
|| `TOTAL_CLICKS` | The number of clicks. ||
|| `AVG_SHOW_POSITION` | The average position of the display. ||
|| `AVG_CLICK_POSITION` | Average click position. ||
|#
<!-- endsource: en/_includes/reference/api-query-indicator.md -->

<!-- source: en/_includes/reference/device-type-indicators.md -->
### Device type indicators (ApiDeviceTypeIndicator) {#device-type-indicators}

#|
|| **Indicator** | **Description** ||
|| `ALL` | All device types. ||
|| `DESKTOP` | Computers. ||
|| `MOBILE_AND_TABLET` | Mobile phones and tablets. ||
|| `MOBILE` | Mobile phones. ||
|| `TABLET` | Tablets. ||
|#

If the request does not specify a device type indicator, the default value is `ALL`.
<!-- endsource: en/_includes/reference/device-type-indicators.md -->

## Response format

### Examples

> 
> {% list tabs %}
> 
> - JSON
> 
>   
>   ```javascript
>   {
>     "queries": [
>       {
>         "query_id": "a08b",
>         "query_text": "some text",
>         "indicators": {
>           "TOTAL_SHOWS": [
>               {
>                   "date": "2019-07-18T00:00:00.000+03:00",
>                   "value": 2.0
>               },
>               ...
>           ]
>       }
>   }               
>   ```
>   
> 
> - XML
> 
>   
>   ```xml
>   <Data>
>       <query>
>           <[query_id](*query_id_desc)>a08b</query_id>
>           <[query_text](*query_text_desc)>some text</query_text>
>           <indicators>
>               <[TOTAL_SHOWS](*ApiQueryIndicator)>
>                   <date>2019-07-18T00:00:00.000+03:00</date>
>                   <value>2.0</value>
>                   ...
>               </TOTAL_SHOWS>
>               ...
>           </indicators>
>       </query>
>   </Data>
>   ```
> 
> {% endlist %}

#|
|| **Name** | **Required** | **Type** | **Description** | **Note** ||
|| `query_id` | Yes | `string` | Search query ID. | — ||
|| `query_text` | Yes | `string` | The text of the search query. | — ||
|| [TOTAL_SHOWS](*ApiQueryIndicator) | Yes | [ApiQueryIndicator](*ApiQueryIndicator) | Search query indicator. | May be omitted if its value is not defined. ||
|#

<!-- source: en/_includes/reference/api-query-indicator.md -->
### Query indicators (ApiQueryIndicator) {#api-query-indicator}

#|
|| **Indicator** | **Description** ||
|| `TOTAL_SHOWS` | The number of displays. ||
|| `TOTAL_CLICKS` | The number of clicks. ||
|| `AVG_SHOW_POSITION` | The average position of the display. ||
|| `AVG_CLICK_POSITION` | Average click position. ||
|#
<!-- endsource: en/_includes/reference/api-query-indicator.md -->

## Response codes

To view the response structure in detail, click the reason.

#|
||
**Code** | **Reason** | **Description**
||
||
200 | OK | 
||
||
404
|
[QUERY_ID_NOT_FOUND](https://yandex.com/dev/webmaster/doc/en/reference/errors.md#query-id-not-found)
|
The specified search query ID does not exist.

{% list tabs %}

- JSON

  ```javascript 
  {   
      "error_code": "QUERY_ID_NOT_FOUND",   
      "error_message": "some string" 
  }
  ```

- XML

  ```xml 
  <Data>   
      <[error_code](*error_code)>QUERY_ID_NOT_FOUND</error_code>     
      <[error_message](*error_message)>some string</error_message> 
  </Data>
  ```

{% endlist %}
||
|#

### Related information

- [Error codes and statuses](https://yandex.com/dev/webmaster/doc/en/reference/errors.md)




[*user-id]: Type: `int64`. User ID. Required when calling all Yandex.Webmaster API resources. To get it, use the [GET /v4/user](https://yandex.com/dev/webmaster/doc/en/reference/user.md) method.

[*host-id]: Type: `host id (string)`. The site ID. To get it, use the [GET /v4/user/{user-id}/hosts](https://yandex.com/dev/webmaster/doc/en/reference/hosts.md) method.

[*query-id]: Type: `string`. Search query ID. To get it, use the [GET /v4/user/{user-id}/hosts/{host-id}/search-queries/popular](https://yandex.com/dev/webmaster/doc/en/reference/host-search-queries-popular.md) method.

[*query_indicator]: Indicators for displaying requests ([ApiQueryIndicator](#api-query-indicator)). You can specify multiple indicators. For example, `query_indicator=TOTAL_SHOWS&query_indicator=TOTAL_CLICKS`.

[*device_type_indicator]: Device type ([ApiDeviceTypeIndicator](#device-type-indicators)). Default value: `ALL`.

[*date_from]: The start date of the range. If omitted, data is returned for the last week.

[*date_to]: The end date of the range. If omitted, data is returned for the last week.

[*ApiQueryIndicator]: ### Query indicators (ApiQueryIndicator) {#api-query-indicator}

#|
|| **Indicator** | **Description** ||
|| `TOTAL_SHOWS` | The number of displays. ||
|| `TOTAL_CLICKS` | The number of clicks. ||
|| `AVG_SHOW_POSITION` | The average position of the display. ||
|| `AVG_CLICK_POSITION` | Average click position. ||
|#

[*ApiDeviceTypeIndicator]: ### Device type indicators (ApiDeviceTypeIndicator) {#device-type-indicators}

#|
|| **Indicator** | **Description** ||
|| `ALL` | All device types. ||
|| `DESKTOP` | Computers. ||
|| `MOBILE_AND_TABLET` | Mobile phones and tablets. ||
|| `MOBILE` | Mobile phones. ||
|| `TABLET` | Tablets. ||
|#

If the request does not specify a device type indicator, the default value is `ALL`.

[*error_code]: **Description**

Error code.

[*error_message]: **Description**

Error message.

[*query_id_desc]: **Required**

Yes

**Type**

`string`

**Description**

Search query ID.

**Note**

—

[*query_text_desc]: **Required**

Yes

**Type**

`string`

**Description**

The text of the search query.

**Note**

—