Kansoku
English日本語简体中文

本页由英文原文翻译,尚未经母语者校对。以英文版为准。 阅读英文原文

快速开始

创建密钥、抽取一个页面、读懂结果。最后一步会告诉你怎么核对刚拿到的数字。目前为早期访问阶段。

早期访问阶段。 API 目前逐个开放给主动联系我们的人,公开注册尚未开放。 本页的命令要在我们发放密钥之后才能运行 —— 现在执行不会通过。 如实写明,是为了不让失败看起来像你这边配置错了。有兴趣请与我们联系

1. 获取密钥

在控制台创建。只显示一次,保存的只有哈希值。 丢失时请重新签发,而不是要求我们找回 —— 我们找不回。

测试密钥以 wi_test_ 开头,正式密钥以 wi_live_ 开头。测试模式的用量 会计量但不会计费,因此可以在产生任何费用之前把接入完整跑一遍。

2. 抽取一个页面

curl -X POST https://api.kansoku.ai/v1/extract \
  -H "Authorization: Bearer $WI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/category/cameras",
    "country": "JP",
    "levels": ["css", "structured_data"],
    "schema": {
      "listings": {
        "type": "list",
        "item": { "name": "string", "price": "number", "currency": "string" }
      }
    }
  }'

levels 是从便宜到贵的阶梯。去掉 llm,就是这次请求不产生任何模型 token 费用的保证 —— 绝大多数商品页根本不需要它。

3. 或者使用 SDK

import { WebIntelligence } from "@wi/sdk";

const wi = new WebIntelligence({ apiKey: process.env.WI_API_KEY! });

const { data, metadata } = await wi.extract.run({
  url: "https://example.com/category/cameras",
  country: "JP",
  levels: ["css", "structured_data"],
  schema: {
    listings: {
      type: "list",
      item: { name: "string", price: "number", currency: "string" },
    },
  } as const,
});

as const 是必需的。有了它,data.listings 才会被推断为记录的数组,否则是 unknown

4. 读取记录

{
  "data": { "listings": [ { "name": "…", "price": 1444300, "currency": "JPY" } ] },
  "metadata": {
    "country": "JP",
    "retrieved_at": "2026-08-21T02:20:04.756Z",
    "request_id": "req_…",
    "level": "structured_data",
    "attempts": [
      { "level": "css", "matched_fields": 0, "duration_ms": 5, "error": null },
      { "level": "structured_data", "matched_fields": 1, "duration_ms": 12, "error": null }
    ],
    "http_status": 200,
    "duration_ms": 1436
  }
}

attempts 恰恰在调用成功时最值得读。 原本 css 就能拿到的页面,现在要落到 structured_data 才行,说明对方改版了。而两者都匹配不上的那一天, 你的数字不是变错,而是变哑。

最后更新