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

# 事件富化指标 API：查询 IP 富化缓存命中率

> Didit 管理 API：查询一段时间内的事件接入与 IP 富化计数，包括缓存命中率、唯一 IP 占比和每千次事件的实时查询次数。

获取事件富化指标 API 提示词
将提示词复制到剪贴板

<pre>
  \`Read the event ingestion and IP-enrichment counters of my Didit application for a period.

  Endpoint:
  GET [https://verification.didit.me/v3/events/enrichment-metrics/?days=30](https://verification.didit.me/v3/events/enrichment-metrics/?days=30)

  Authentication:
  Use the x-api-key header with my Didit API key. A scoped key needs transactions: read.

  Goal:

  * Monitor event volume and confirm that IP enrichment is resolved once per unique address rather than once per event, for a usage dashboard or an alert.

  Behavior:

  * days defaults to 30 and is clamped to 1-365; a non-integer value falls back to 30.
  * The period covers today plus the previous days days, by UTC calendar day.
  * Counters are summed over every lane (server, batch and device).
  * The three ratios are null when their denominator is zero.

  Example call:
  curl -X GET "[https://verification.didit.me/v3/events/enrichment-metrics/?days=30](https://verification.didit.me/v3/events/enrichment-metrics/?days=30)" \
  -H "x-api-key: YOUR\_API\_KEY"

  What to read from the response:

  * events\_ingested - new events stored (replays are not counted).
  * events\_rejected - items rejected inside batch requests (a rejected single-event request is not counted).
  * enrichment\_lookups - events whose public IP address was resolved; enrichment\_cache\_hits - answered from the cache; enrichment\_provider\_calls - needed a fresh resolution.
  * enrichment\_skipped\_low\_value - low-value telemetry whose address was not cached; it never triggers a lookup of its own.
  * unique\_ips\_seen - distinct addresses that needed a fresh resolution.
  * cache\_hit\_rate, unique\_ip\_ratio, provider\_calls\_per\_1k\_events - the ratios.
  * period\_days - the period actually applied.

  Failure modes:

  * 401 - the API key has expired.
  * 403 - missing API key (a wrong, revoked or expired key gets 401), or a scoped key without transactions: read.

  Side effects: none. This is a pure read.

  For the full integration shape, see /integration/integration-prompt.\`
</pre>

粘贴到

Business Console 在事件列表上方显示相同的数字。有关低价值遥测数据为何仅在另一事件已解析该地址时才读取富化结果，请参阅事件接入指南中的 [IP 富化](https://docs.didit.me/zh/transaction-monitoring/events.md#ip-丰富信息)；有关已富化地址所包含字段的说明，请参阅 [IP 富化](https://docs.didit.me/zh/transaction-monitoring/ip-enrichment.md)。


## OpenAPI

````yaml zh/openapi-25.json GET /v3/events/enrichment-metrics/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: 身份证件验证 API。使用 x-api-key 请求头进行身份验证。
servers:
  - url: https://verification.didit.me
security: []
tags: []
paths:
  /v3/events/enrichment-metrics/:
    get:
      tags:
        - Monitoring Events
      summary: 获取事件丰富化指标
      description: >-
        返回您的应用在指定时间段内的事件摄入和 IP
        信息丰富计数器，汇总所有通道（服务器、批处理和设备），以便您可以监控事件量并确认每个唯一地址的信息丰富操作仅解析一次，而不是针对每个事件解析一次。该时间段涵盖今天加上之前的
        `days` 天，按 UTC 日历日期计算。当分母为零时，这三个比率为 null。限定作用域的 API 密钥需要 `transactions:
        read`。请参阅 [IP
        信息丰富](https://docs.didit.me/zh/transaction-monitoring/events#ip-丰富信息)。
      operationId: get_monitoring_event_enrichment_metrics
      parameters:
        - name: days
          in: query
          required: false
          description: >-
            周期长度（天）。默认值为 30；值会被限制在 1 到 365 之间，非整数值将回退到 30。实际应用的值作为 `period_days`
            返回。
          schema:
            type: integer
            default: 30
            minimum: 1
            maximum: 365
          example: 30
      responses:
        '200':
          description: 该时间段内的计数器和比率。
          content:
            application/json:
              schema:
                type: object
                required:
                  - events_ingested
                  - events_rejected
                  - enrichment_lookups
                  - enrichment_cache_hits
                  - enrichment_provider_calls
                  - enrichment_skipped_low_value
                  - unique_ips_seen
                  - period_days
                  - cache_hit_rate
                  - unique_ip_ratio
                  - provider_calls_per_1k_events
                properties:
                  events_ingested:
                    type: integer
                    description: 已存储新事件。幂等重放不计数。
                  events_rejected:
                    type: integer
                    description: 批量请求（服务端通道和设备通道）中被拒绝的项目。被拒绝的单事件请求不计入在内。
                  enrichment_lookups:
                    type: integer
                    description: 已解析公网 IP 地址的事件，数据来自缓存或最新获取。
                  enrichment_cache_hits:
                    type: integer
                    description: 从缓存中直接返回的查询。
                  enrichment_provider_calls:
                    type: integer
                    description: 需要对地址进行全新解析的查询。
                  enrichment_skipped_low_value:
                    type: integer
                    description: 其地址尚属未知的低价值遥测事件。它们本身绝不会触发全新解析。
                  unique_ips_seen:
                    type: integer
                    description: 需要重新解析的地址。
                  period_days:
                    type: integer
                    description: 限制范围后应用的 `days` 值。
                  cache_hit_rate:
                    type: number
                    nullable: true
                    description: >-
                      `enrichment_cache_hits / enrichment_lookups`，四舍五入保留 4
                      位小数。没有查询时为 Null。
                  unique_ip_ratio:
                    type: number
                    nullable: true
                    description: >-
                      `unique_ips_seen / events_ingested`，保留 4 位小数。未摄取任何事件时为
                      null。
                  provider_calls_per_1k_events:
                    type: number
                    nullable: true
                    description: 每 1000 个摄入事件的新增解析数，四舍五入保留 2 位小数。未摄入事件时为 null。
              examples:
                Last 30 days:
                  value:
                    events_ingested: 128450
                    events_rejected: 214
                    enrichment_lookups: 41230
                    enrichment_cache_hits: 40118
                    enrichment_provider_calls: 1112
                    enrichment_skipped_low_value: 74320
                    unique_ips_seen: 1112
                    period_days: 30
                    cache_hit_rate: 0.973
                    unique_ip_ratio: 0.0087
                    provider_calls_per_1k_events: 8.66
                No events yet:
                  value:
                    events_ingested: 0
                    events_rejected: 0
                    enrichment_lookups: 0
                    enrichment_cache_hits: 0
                    enrichment_provider_calls: 0
                    enrichment_skipped_low_value: 0
                    unique_ips_seen: 0
                    period_days: 30
                    cache_hit_rate: null
                    unique_ip_ratio: null
                    provider_calls_per_1k_events: null
        '401':
          description: 作用域 API 密钥已过期。仅过期的密钥会收到 `401`；缺失或无效的密钥会收到 `403`。
          content:
            application/json:
              examples:
                Expired key:
                  value:
                    detail: This API key has expired.
        '403':
          description: >-
            缺少 `x-api-key`（错误、已撤销或已过期的密钥会返回 `401`）、无 `transactions: read`
            权限的作用域密钥、仅限于某些工作流或已通过会话的密钥（此类密钥绝无法访问交易监控数据），或来自密钥 IP 白名单之外的请求。
          content:
            application/json:
              examples:
                Missing or invalid API key:
                  value:
                    detail: You do not have permission to perform this action.
                Scoped key without access:
                  value:
                    detail: This API key has no read access to transactions.
                Key limited to workflows or approved sessions:
                  value:
                    detail: >-
                      This API key only reaches sessions inside its workflow or
                      status limits, so it can't use this endpoint.
                IP not allowed:
                  value:
                    detail: This API key can't be used from this IP address.
        '429':
          description: 超出速率限制：每个 API 密钥的 `GET` 请求共享每分钟 600 次的配额。请等待 `Retry-After` 秒，然后重试。
          headers:
            Retry-After:
              description: 重试前需要等待的秒数。
              schema:
                type: integer
                minimum: 1
                example: 30
          content:
            application/json:
              examples:
                Throttled:
                  value:
                    detail: >-
                      GET request rate limit exceeded. You can make up to 600
                      requests per minute.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl -X GET
            'https://verification.didit.me/v3/events/enrichment-metrics/?days=30'
            \
              -H 'x-api-key: YOUR_API_KEY'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.monitoring_events.retrieve_enrichment_metrics()
            print(result)
        - lang: javascript
          label: Node.js
          source: >-
            import Didit from "@didit-protocol/sdk-node";


            // Reads DIDIT_API_KEY.

            const didit = new Didit();


            const result = await
            didit.monitoringEvents.retrieveEnrichmentMetrics();

            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.MonitoringEvents.RetrieveEnrichmentMetrics(ctx, didit.MonitoringEventsRetrieveEnrichmentMetricsParams{})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: |-
            import me.didit.Didit;

            // Reads DIDIT_API_KEY.
            Didit client = new Didit();

            var result = client.monitoringEvents().retrieveEnrichmentMetrics();
            System.out.println(result);
        - lang: php
          label: PHP
          source: |-
            <?php

            require 'vendor/autoload.php';

            use Didit\DiditClient;

            // Reads DIDIT_API_KEY.
            $didit = new DiditClient();

            $result = $didit->monitoringEvents->retrieveEnrichmentMetrics();
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

            # Reads DIDIT_API_KEY.
            didit = Didit::Client.new

            result = didit.monitoring_events.retrieve_enrichment_metrics
            puts result.to_h
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using System.Text.Json;

            using Didit;


            // Reads DIDIT_API_KEY.

            using var client = new DiditClient();


            var result = await
            client.MonitoringEvents.RetrieveEnrichmentMetricsAsync();

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        您的应用 API 密钥，可在 Business Console 的“开发者 -> API
        密钥”中获取。主密钥拥有完整访问权限。指定名称的密钥可设置作用域：针对每个资源设为无权限、只读或读写，限定于特定工作流或已通过的会话、限定于
        IP 地址列表，以及设置到期日期。401 表示密钥错误、已撤销或已过期；403 表示未发送密钥、密钥无权访问该资源或操作，或请求来自其 IP
        列表之外的地址；在会话路由上返回 404 表示该会话不在该密钥允许的工作流或状态范围内。没有媒体访问权限的密钥获取到的图片、视频和 PDF
        URL 将为 null；没有会话写入权限的密钥获取到的会话链接和 token 将为 null。请参阅
        https://docs.didit.me/console/api-keys。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.