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

# 导出原始分析数据

> POST /analytics/qr/raw/

导出**原始的、按次扫描**的分析记录——每条扫描事件对应一行，而不是 [二维码分析](/zh/api-reference/management-api/analytics/qr-analytics) 和 [导出分析数据](/zh/api-reference/management-api/analytics/export) 所返回的聚合细分数据。

<Warning>
  这是一个**仅支持 POST** 的端点——`GET` 请求会返回 `405 Method Not Allowed`。`management-api.json` 规范此前将其列为 `GET`；此问题已被修正。
</Warning>

<Note>
  需要一个拥有 `MANAGEMENT_API` 配额的 Management API 密钥——参见 [Management API 概览](/zh/api-reference/management-api/overview)——外加账户的 `EXPORT_ANALYTICS_REPORT` 配额和 `ANALYTICS_CAN_EXPORT_RAW` 权限（这与聚合导出所需的 `ANALYTICS_CAN_EXPORT` 权限是不同的两项权限——一个角色可以拥有其中一项而没有另一项）。返回 403 并附带 `"Your plan does not have export analytics report quota."` 消息，说明该套餐不包含导出功能。
</Note>

## 请求

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://management.scanova.io/analytics/qr/raw/?from=2026-07-01&to=2026-08-16&file_format=csv' \
    --header 'Authorization: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "q": ["Q07afe81aa0034c01"],
      "filter_by": "qrid"
    }' \
    --output raw-analytics.csv
  ```
</RequestExample>

此端点始终返回二进制文件，而非 JSON。

### 查询参数

<ParamField query="from" type="string" required>
  起始日期（`YYYY-MM-DD`），含当天。
</ParamField>

<ParamField query="to" type="string" required>
  结束日期（`YYYY-MM-DD`），含当天。
</ParamField>

<ParamField query="file_format" type="string" required>
  `csv`、`xls` 或 `xlsx`。与 [导出分析数据](/zh/api-reference/management-api/analytics/export) 不同，此处不支持 `pdf` 格式。任何其他值（或省略该参数）都会返回一个附带 `"Invalid file format"` 的 `400` 错误。
</ParamField>

<ParamField query="type" type="string">
  传入 `raw_bot` 以仅导出被识别为机器人的扫描记录，而非全部扫描。传入其他任何值都会被覆盖——无论您在此传入什么，该端点始终导出原始数据。
</ParamField>

### 请求体

与 [二维码分析](/zh/api-reference/management-api/analytics/qr-analytics#request-body) 的数据结构相同——`q`（必填）和 `filter_by`（默认 `qrid`）用于限定要包含哪些二维码的原始扫描数据，并且适用相同的[二维码数量/日期范围数据量限制](/zh/api-reference/management-api/analytics/qr-analytics#request)。

<ParamField body="q" type="array" required>
  用于限定导出范围的标识符——具体类型取决于 `filter_by`。
</ParamField>

<ParamField body="filter_by" type="string" default="qrid">
  `qrid`、`id`、`tags` 或 `folder` 之一。
</ParamField>

### 响应格式

<Tabs>
  <Tab title="csv">
    返回一个单独的 CSV 文件（`text/csv`，`analytics_raw.csv`），包含原始扫描行数据。
  </Tab>

  <Tab title="xls / xlsx">
    返回一个电子表格文件（`analytics_raw.xlsx`），包含原始扫描行数据；如果账户启用了事件跟踪功能，还会附带一个单独的工作表，用于存放事件跟踪的原始记录。
  </Tab>
</Tabs>

<Note>
  如果账户启用了事件跟踪分析功能，**并且** `file_format` 不是 `csv`，则会自动追加第二个工作表/区块，包含事件跟踪原始记录（会话 ID、时间戳、二维码 ID/名称、用户指定的事件跟踪 ID、URL 哈希值、URL）。请求 `csv` 时始终只返回扫描记录——该格式下会专门省略事件跟踪相关的行。
</Note>

## 相关内容

* [二维码分析](/zh/api-reference/management-api/analytics/qr-analytics) —— 这些原始扫描记录的聚合、JSON 等价形式。
* [导出分析数据](/zh/api-reference/management-api/analytics/export) —— 导出聚合后的指标细分数据，而不是逐行的扫描数据。
* [Management API 概览](/zh/api-reference/management-api/overview) —— 本端点所属的身份验证方案与配额架构。


## OpenAPI

````yaml api-reference/openapi/management-api.json POST /analytics/qr/raw/
openapi: 3.1.0
info:
  title: Scanova Management API (v2)
  description: >-
    The complete Scanova Management API — every endpoint available at
    management.scanova.io (QR codes, folders, tags, leads, forms, analytics,
    plans, shared users & roles), plus the token-creation and usage-stats
    endpoints used to authenticate against it. Every path and request/response
    shape below was verified live against a real API key and the actual running
    backend (Phase 7, 2026-08-16) — not guessed from reading urls.py alone.
  version: 2.0.0
servers:
  - url: https://management.scanova.io
    description: Management API — QR/folder/tag/lead/form/analytics/plans endpoints
security:
  - apiKeyAuth: []
paths:
  /analytics/qr/raw/:
    post:
      summary: Export raw analytics
      description: >-
        Exports raw, per-scan analytics records (one row per scan) as csv, xls,
        or xlsx (no pdf). POST-only; shares its request body and volume-cap
        validation with /analytics/qr/. Pass type=raw_bot as a query parameter
        to export bot-only scan records instead of all scans.
      operationId: exportManagedRawAnalytics
      parameters:
        - name: from
          in: query
          required: true
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: true
          schema:
            type: string
            format: date
        - name: file_format
          in: query
          required: true
          schema:
            type: string
            enum:
              - csv
              - xls
              - xlsx
        - name: type
          in: query
          schema:
            type: string
            enum:
              - raw_bot
          description: >-
            Pass raw_bot for a bot-only export; any other value is overwritten
            to raw.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                q:
                  type: array
                  items:
                    type: string
                filter_by:
                  type: string
                  enum:
                    - qrid
                    - tags
                    - id
                    - folder
                  default: qrid
              required:
                - q
            example:
              q:
                - Q07afe81aa0034c01
              filter_by: qrid
      responses:
        '200':
          description: >-
            Binary file download — text/csv for csv, spreadsheet mimetype for
            xls/xlsx.
          content:
            text/csv: {}
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet: {}
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Send your Management API key as the raw value of the Authorization
        header — no "Bearer " or "Token " prefix, and no other characters.
        Example: `Authorization: 401f7ac837da42b97f613d789819ff93537bee6a`. A
        header containing more than one space-separated part is rejected
        outright. Requests also require the request's Host header to be the
        management API host (e.g. management.scanova.io) — the same key sent to
        the regular API host will not authenticate.

````