> ## Documentation Index
> Fetch the complete documentation index at: https://www.mintlify.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取搜索查询

> 导出 Mintlify 文档的搜索查询记录，包含每个搜索词的命中数、点击率以及最近一次被搜索的时间，便于分析用户搜索行为。

<div id="usage">
  ## 使用方法
</div>

使用此端点导出文档搜索分析数据。结果按命中次数从高到低排序，显示用户最常搜索的词语。

使用响应中返回的 `nextCursor` 参数对结果进行分页。当 `nextCursor` 不为 null 时继续获取数据。

<div id="filtering">
  ## 筛选
</div>

使用 `dateFrom` 和 `dateTo` 参数按日期范围过滤搜索数据。

<div id="rate-limits">
  ## 速率限制
</div>

此端点允许每个组织每小时最多 100 次请求。所有分析端点共享此限制。


## OpenAPI

````yaml zh/analytics.openapi.json GET /v1/analytics/{projectId}/searches
openapi: 3.1.0
info:
  title: Mintlify Analytics Export API
  version: 1.0.0
  description: API for exporting documentation analytics data
servers:
  - url: https://api.mintlify.com
    description: Production
security: []
paths:
  /v1/analytics/{projectId}/searches:
    get:
      tags:
        - Analytics
      summary: Get search queries
      description: >-
        Returns paginated documentation search terms for the date range, ordered
        by hit count descending. Each row includes click-through rate, the
        most-clicked result path for that query (if any), and the last time the
        term was searched. `totalSearches` is the total number of search query
        events in the same date range (sum of all hits, not distinct queries).


        Authenticate with an admin API key.
      parameters:
        - $ref: '#/components/parameters/projectId'
        - schema:
            type: string
            description: Date in ISO 8601 or YYYY-MM-DD format
            example: '2024-01-01'
          required: false
          name: dateFrom
          in: query
        - schema:
            type: string
            description: >-
              Date in ISO 8601 or YYYY-MM-DD format. `dateTo` is an exclusive
              upper limit. Results include dates before, but not on, the
              specified date.
            example: '2024-01-01'
          required: false
          name: dateTo
          in: query
        - schema:
            type: number
            minimum: 1
            maximum: 100
            default: 50
            description: Max search terms per page (ordered by hit count descending)
          required: false
          name: limit
          in: query
        - schema:
            type: string
            description: Opaque pagination cursor from the previous response
          required: false
          name: cursor
          in: query
      responses:
        '200':
          description: Search term aggregates with pagination
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchesResponse'
        '400':
          description: Invalid query parameters or cursor
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsErrorResponse'
      security:
        - bearerAuth: []
components:
  parameters:
    projectId:
      schema:
        $ref: '#/components/schemas/projectId'
      required: true
      name: projectId
      in: path
  schemas:
    SearchesResponse:
      type: object
      properties:
        searches:
          type: array
          description: Search terms ordered by hit count descending.
          items:
            type: object
            properties:
              searchQuery:
                type: string
                description: The search term entered by users.
              hits:
                type: number
                description: Number of times this term was searched.
              ctr:
                type: number
                description: Click-through rate for this search term.
              topClickedPage:
                type:
                  - string
                  - 'null'
                description: The most-clicked result path for this query, if any.
              lastSearchedAt:
                type: string
                description: Timestamp of the last time this term was searched.
            required:
              - searchQuery
              - hits
              - ctr
              - topClickedPage
              - lastSearchedAt
        totalSearches:
          type: integer
          minimum: 0
          description: >-
            Total count of search events in the requested date range (sum of all
            hits, not distinct queries).
        nextCursor:
          type:
            - string
            - 'null'
          description: Opaque pagination cursor for the next page. Null if no more results.
      required:
        - searches
        - totalSearches
        - nextCursor
    AnalyticsErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message describing what went wrong.
        details:
          type: array
          description: Additional details about the error.
          items:
            type: object
            properties:
              message:
                type: string
                description: Description of a specific validation or processing error.
            required:
              - message
      required:
        - error
    projectId:
      type: string
      description: >-
        Your project ID. Can be copied from the [API
        keys](https://app.mintlify.com/settings/organization/api-keys) page in
        your dashboard.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        The Authorization header expects a Bearer token. Use an admin API key.
        This is a server-side secret key. Generate one on the [API keys
        page](https://app.mintlify.com/settings/organization/api-keys) in your
        dashboard.

````

## Related topics

- [分析](/docs/zh/optimize/analytics.md)
- [Mixpanel](/docs/zh/integrations/analytics/mixpanel.md)
- [简介](/docs/zh/api/introduction.md)
