> 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`                                                              | 启用按日、月或年显示使用统计信息（而不是显示总统计信息）                 | `天`, `月`, `年`                                                                                                       | `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

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

# 将格式化后的 JSON 响应打印到 stdout。
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 'Error:' . 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:

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

The question should be specific, self-contained, and written in natural language.
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.
