> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/web-scraper-api/usage-and-billing/usage-statistics.md).

# 使用统计

你可以通过提交 API 请求免费查看你的使用统计。

下方的端点用于查询使用统计：

```
GET https://data.oxylabs.io/v2/stats
```

### 输入

默认情况下，API 会返回未筛选的（全部时间、所有来源）使用统计。你也可以获取分组和/或筛选后的统计。

你可以在同一个查询中组合两个或更多参数，例如按天分组统计并按来源筛选。

| 参数                                                                        | 描述                                           | 有效值                                                                                                                 | URL 示例                                                      |
| ------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| `group_by`                                                                | 启用按日、按月或按年的使用统计显示（而不是显示总统计）                  | `day`, `month`, `year`                                                                                              | `https://data.oxylabs.io/v2/stats?group_by=day`             |
| `date_from`                                                               | 下限日期边界。最好与 `date_to`.                        | 任意日期，格式为 `Y-m-d` 格式。                                                                                                | `https://data.oxylabs.io/v2/stats?date_from=2022-01-17`     |
| `date_to`                                                                 | 上限日期边界。最好与 `date_from`.                      | 任意日期，格式为 `Y-m-d` 格式。                                                                                                | `https://data.oxylabs.io/v2/stats?date_to=2022-06-17`       |
| `source`                                                                  | 可让你获取单个 `source` 你选择的。                       | 任何有效的 `source` 值分隔。                                                                                                 | `https://data.oxylabs.io/v2/stats?source=universal`         |
| <p><code>product</code><br><br>此筛选器适用于旧版用户（在 2024 年 9 月 25 日之前创建的账号）。</p> | 可让你获取你选择的单个产品的使用统计。仅在你使用同一用户名访问多个网页爬虫API时适用。 | <p><code>serp\_scraper\_api</code>;</p><p><code>ecommerce\_scraper\_api</code> ; <code>web\_scraper\_api</code></p> | `https://data.oxylabs.io/v2/stats?product=serp_scraper_api` |

以下查询返回按月统计。

{% tabs %}
{% tab title="cURL" %}

```shell
curl --user "user:pass1" 'https://data.oxylabs.io/v2/stats?group_by=month'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint

# 从统计端点获取响应。
response = requests.request(
    method='GET',
    url='https://data.oxylabs.io/v2/stats',
    auth=('user', 'pass1'),
)

# 将格式化后的 JSON 响应打印到标准输出。
pprint(response.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://data.oxylabs.io/v2/stats");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo '错误:' . curl_error($ch);
}
curl_close ($ch);
?>
```

{% endtab %}
{% endtabs %}

### 输出

该 `v2/stats` 输出包含使用统计，包括产品级统计（电商爬虫 API / SERP 爬虫 API / 网页爬虫API）。产品级统计会细分为来源级统计，而来源级统计又进一步细分为 HTML 和解析结果的独立统计。请参见 [**数据字典**](#data-dictionary) 章节，了解每个输出键的含义。

#### 示例输出

```json
{
    "meta": {
        "group_by": null,
        "date_from": null,
        "date_to": null,
        "source": null,
        "product": null
    },
    "data": {
        "products": [
            {
                "all_count": 5837,
                "mode_callback_count": 5514,
                "mode_realtime_count": 315,
                "mode_superapi_count": 8,
                "contenttype_parsed_count": 56,
                "contenttype_html_count": 5781,
                "render_count": 3,
                "geo_location_count": 2330,
                "average_response_time": 88.54,
                "request_traffic": 4685091,
                "response_traffic": 602064208,
                "title": "serp_scraper_api",
                "sources": [
                    {
                        "all_count": 5616,
                        "mode_callback_count": 5414,
                        "mode_realtime_count": 194,
                        "mode_superapi_count": 8,
                        "render_count": 0,
                        "geo_location_count": 2190,
                        "average_response_time": 91.59,
                        "request_traffic": 4550507,
                        "response_traffic": 585423946,
                        "title": "serp_source1",
                        "parsed": false
                    },
                    {
                        "all_count": 1,
                        "mode_callback_count": 0,
                        "mode_realtime_count": 1,
                        "mode_superapi_count": 0,
                        "render_count": 0,
                        "geo_location_count": 1,
                        "average_response_time": 11,
                        "request_traffic": 0,
                        "response_traffic": 0,
                        "title": "serp_source2",
                        "parsed": false
                    }
                ]
            }
        ]
    }
}
```

### 数据字典

| 键                          | 描述                                 | 类型      |
| -------------------------- | ---------------------------------- | ------- |
| `meta`                     | 所有提交统计的容器 [**查询参数**](#input).      | -       |
| `data`                     | 所有统计数据的容器。                         | JSON 对象 |
| `products`                 | 产品级统计对象列表。                         | JSON 数组 |
| `all_count`                | 结果总数。                              | 整数      |
| `mode_callback_count`      | 通过 Push-Pull 集成方式完成的结果数量。          | 整数      |
| `mode_realtime_count`      | 通过 Realtime 集成方式完成的结果数量。           | 整数      |
| `mode_superapi_count`      | 通过 Proxy Endpoint 集成方式完成的结果数量。     | 整数      |
| `contenttype_parsed_count` | 解析结果数量。                            | 整数      |
| `contenttype_html_count`   | HTML 结果数量。                         | 整数      |
| `render_count`             | 通过执行 JavaScript 完成的结果数量。           | 整数      |
| `geo_location_count`       | 通过用户定义的 `geo_location` 参数值完成的结果数量。 | 整数      |
| `average_response_time`    | 平均响应时间（秒）。                         | 浮点数     |
| `request_traffic`          | 总 **请求** 流量（字节）。                   | 整数      |
| `response_traffic`         | 总 **响应** 流量（字节）。                   | 整数      |
| `title`                    | 产品或来源名称。                           | 字符串     |
| `sources`                  | 属于某个产品的来源列表。                       | 字符串     |
| `parsed`                   | 指示 JSON 对象中的数据是否属于解析结果。            | 布尔值     |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/products/cn/web-scraper-api/usage-and-billing/usage-statistics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
