> ## 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.

# 用量统计

> GET /console/usage/

返回给定密钥 environment 在一个滚动时间窗口内的请求次数总计。与其他 `console/` 端点一样，此端点位于**常规**的 Scanova API 主机（`qcg-api.scanova.io`）上，使用您的仪表盘 OAuth 访问令牌进行身份验证。

<Note>
  数据是**跨账户下所有共享同一 `environment` 的密钥**进行聚合的，而不是单一密钥的数据。如果您想要某一个密钥的终身总用量，那是 [`GET /console/token/`](/zh/api-reference/management-api/tokens/create#listing-existing-tokens) 返回的 `usage_count` 字段。
</Note>

## 请求

```
GET https://qcg-api.scanova.io/console/usage/
Authorization: Bearer <your_oauth_access_token>
```

<ParamField query="environment" type="string" required>
  `sandbox`、`live`、`zapier`、`mcp` 之一。选择要聚合哪些密钥的日志。
</ParamField>

<ParamField query="period" type="string" default="week">
  `day`、`week`、`month`、`year` 之一。截至当前的滚动时间窗口，请求会在此窗口内被统计。
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -G "https://qcg-api.scanova.io/console/usage/" \
    -H "Authorization: Bearer <your_oauth_access_token>" \
    -d environment=live \
    -d period=month
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "total_requests": 4820,
    "successful_requests": 4761,
    "failed_requests": 59
  }
  ```
</ResponseExample>

### 响应字段

<ResponseField name="total_requests" type="integer">
  此 environment 下的密钥在该时间窗口内记录的请求总数。
</ResponseField>

<ResponseField name="successful_requests" type="integer">
  返回状态码低于 `400` 的请求数。
</ResponseField>

<ResponseField name="failed_requests" type="integer">
  返回状态码为 `400` 或以上的请求数。
</ResponseField>

## 错误

`environment` 为必填项——省略它，或传入上述四个值之外的其他值，都会返回：

```json 400 Bad Request theme={null}
{ "environment": ["A valid environment is required."] }
```

无效的 `period` 会返回：

```json 400 Bad Request theme={null}
{ "period": ["period must be one of day, week, month, year."] }
```

<Note>
  Management API 目前没有强制执行任何速率限制——这些用量端点的存在纯粹是为了提供可见性，而不是用于配额管控。按天的趋势请参见[每日用量](/zh/api-reference/management-api/tokens/usage-daily)，按路由拆分的明细请参见[按端点统计用量](/zh/api-reference/management-api/tokens/usage-by-endpoint)。
</Note>

## 相关内容

* [每日用量](/zh/api-reference/management-api/tokens/usage-daily) —— 同样的数字，按日历日拆分。
* [按端点统计用量](/zh/api-reference/management-api/tokens/usage-by-endpoint) —— 同样的数字，按路由和方法拆分。
* [创建一个 API 令牌](/zh/api-reference/management-api/tokens/create) —— 单个密钥的终身 `usage_count` 字段（与此处的 environment 级总量不同）的来源。


## OpenAPI

````yaml api-reference/openapi/management-api.json GET /console/usage/
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:
  /console/usage/:
    get:
      summary: Usage statistics
      operationId: getUsageStats
      parameters:
        - name: environment
          in: query
          required: true
          schema:
            type: string
        - name: period
          in: query
          schema:
            type: string
            enum:
              - day
              - week
              - month
              - year
      responses:
        '200':
          description: Usage stats
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.

````