快速开始

一句话接入

把下面任意一句发给你正在用的 Agent,它会先向你要数据钥匙,再帮你把 MCP 配置好:

自包含短句:接入 With3 数据接口:MCP 地址 https://api.with3.ai/mcp,认证用请求头 Authorization: Bearer 我的数据 Key;先问我要 Key,再帮我配置好。

可联网的 Agent:接入 With3 数据接口,按 https://api.with3.ai/data/mcp/install 的说明安装。

Agent 安装说明(给 Agent 读取的纯文本):https://api.with3.ai/data/mcp/install。

四步接入

  1. 获取 Key:账户和 Key 由我方工作人员按客户邮箱创建;一个账户可以有多把命名 Key,可分别重新生成或撤销。Key 明文只在创建或重新生成时显示一次,请立即保存。
  2. 查看价格与授权范围:每把 Key 只能调用被授权的接口,未授权返回 403; 单价以文档页公布为准,账户页显示该账户 余额与这把 Key 的已授权接口。
  3. 充值:按实际收款凭证入账,单次充值不少于 ¥3,000;余额不足的付费请求返回 402。
  4. 开始调用:使用下面的示例发起请求;每次成功调用按该接口单价扣费一次, 失败或空结果会退款。

基础约定

示例接口与价格

示例接口 /data/v1/xiaohongshu/app_v2/search_notes(搜索笔记)当前单价 ¥0.108(成功才计费),价格来自文档页。如果该示例接口未开放或这把 Key 未被授权,调用会返回 403。

多语言示例

Python(requests)

import uuid

import requests

BASE = "https://api.with3.ai/data"
KEY = "<数据Key>"
HEADERS = {"Authorization": f"Bearer {KEY}"}

# ① 查询余额与已授权接口(免费)
account = requests.get("https://api.with3.ai/account/v1/balance", headers=HEADERS, timeout=30)
print(account.status_code, account.json())

# ② 调用已验证示例(单价:¥0.108(成功才计费));重试请复用同一个 Idempotency-Key
response = requests.get(
    f"{BASE}/v1/xiaohongshu/app_v2/search_notes",
    params={"keyword": "咖啡", "page": 1},
    headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())},
    timeout=60,
)
print(response.status_code, response.text)

JavaScript(Node 18+ fetch)

// 保存为 quickstart.mjs,并用 `node quickstart.mjs` 运行(Node 18+)
import { randomUUID } from "node:crypto";

const BASE = "https://api.with3.ai/data";
const KEY = "<数据Key>";
const headers = { Authorization: `Bearer ${KEY}` };

// ① 查询余额与已授权接口(免费)
const account = await fetch("https://api.with3.ai/account/v1/balance", { headers });
console.log(account.status, await account.json());

// ② 调用已验证示例(单价:¥0.108(成功才计费));重试请复用同一个 Idempotency-Key
const response = await fetch(
  `${BASE}/v1/xiaohongshu/app_v2/search_notes?keyword=${encodeURIComponent("咖啡")}&page=1`,
  { headers: { ...headers, "Idempotency-Key": randomUUID() } },
);
console.log(response.status, await response.text());

cURL

# ① 查询余额与已授权接口(免费)
curl -s https://api.with3.ai/account/v1/balance \
  -H "Authorization: Bearer <数据Key>"

# ② 调用已验证示例(单价:¥0.108(成功才计费));重试请复用同一个 Idempotency-Key
curl -s "https://api.with3.ai/data/v1/xiaohongshu/app_v2/search_notes?keyword=%E5%92%96%E5%95%A1&page=1" \
  -H "Authorization: Bearer <数据Key>" \
  -H "Idempotency-Key: <随机UUID>"

Go(net/http)

package main

import (
    "crypto/rand"
    "encoding/hex"
    "fmt"
    "io"
    "net/http"
)

// newKey 生成一个随机 Idempotency-Key(重试请复用同一个)。
func newKey() string {
    b := make([]byte, 16)
    _, _ = rand.Read(b)
    return hex.EncodeToString(b)
}

func get(url, idem string) {
    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Set("Authorization", "Bearer <数据Key>")
    if idem != "" {
        req.Header.Set("Idempotency-Key", idem)
    }
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(resp.StatusCode, string(body))
}

func main() {
    base := "https://api.with3.ai/data"
    // ① 查询余额与已授权接口(免费)
    get("https://api.with3.ai/account/v1/balance", "")
    // ② 调用已验证示例(单价:¥0.108(成功才计费))
    get(base+"/v1/xiaohongshu/app_v2/search_notes?keyword=%E5%92%96%E5%95%A1&page=1", newKey())
}

Java(java.net.http.HttpClient)

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.UUID;

public class Example {
    static final String BASE = "https://api.with3.ai/data";
    static final String KEY = "<数据Key>";

    static void get(String url, String idem) throws Exception {
        HttpRequest.Builder builder = HttpRequest.newBuilder(URI.create(url))
                .header("Authorization", "Bearer " + KEY);
        if (idem != null) {
            builder.header("Idempotency-Key", idem);
        }
        HttpResponse<String> response = HttpClient.newHttpClient()
                .send(builder.build(), HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }

    public static void main(String[] args) throws Exception {
        // ① 查询余额与已授权接口(免费)
        get("https://api.with3.ai/account/v1/balance", null);
        // ② 调用已验证示例(单价:¥0.108(成功才计费))
        get(BASE + "/v1/xiaohongshu/app_v2/search_notes?keyword=%E5%92%96%E5%95%A1&page=1", UUID.randomUUID().toString());
    }
}

电商类接口

接口文档页按类别分组,目前有「社交媒体」和「电商」两类。电商类里的京东商品标价按 SKU 批量查标价(不是券后价、到手价或 PLUS 价),一次 1–20 个 SKU。

curl -s https://api.with3.ai/data/v1/ecommerce/jd/price \
  -H "Authorization: Bearer <数据Key>" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <随机UUID>" \
  -d '{"skus": ["100012043978", "100012043979"]}'

返回每个 SKU 一项,check 说明价格可信度(通过 / 待人工核 / 未校验):

{
  "code": 200,
  "data": {
    "price_type": "标价(非到手价)",
    "count": 2,
    "items": [
      {"sku": "100012043978", "price": "1299", "price_type": "标价(非到手价)",
       "check": "通过", "note": "打码价 1??9 与取价 1299 位数/首末位一致", "source": "primary"},
      {"sku": "100012043979", "price": null, "price_type": "标价(非到手价)",
       "check": "待人工核", "note": "各来源均未取到标价", "source": null}
    ]
  }
}

至少一个 SKU 有价格时计费一次;全部没有价格不收费。该接口需在钥匙上开通并授权后才能调用;未开通时调用会被拒绝。

Agent 接入(MCP)

支持 MCP 的客户端可以用一条 URL 加数据 Key 接入: POST https://api.with3.ai/mcp, Authorization: Bearer <数据Key>。三个工具: list_interfaces(先发现可调用接口)、call_interface(经现有网关调用)与 get_account(只读余额与已授权接口)。付费调用同样按次计费,失败或空结果退款。

Claude Code: claude mcp add --transport http with3-data-api https://api.with3.ai/mcp --header "Authorization: Bearer <数据Key>"。

Cursor(mcp.json 顶层用 mcpServers):
{"mcpServers":{"with3-data-api":{"type":"http","url":"https://api.with3.ai/mcp","headers":{"Authorization":"Bearer <数据Key>"}}}}

VS Code(mcp.json 顶层用 servers):
{"servers":{"with3-data-api":{"type":"http","url":"https://api.with3.ai/mcp","headers":{"Authorization":"Bearer <数据Key>"}}}}

模型接口

地址:https://api.with3.ai/model/v1,兼容 OpenAI API。 使用 Authorization: Bearer <key> 认证。

POST /chat/completions 生成回复;GET /models 查询当前钥匙可用的模型。 模型名以 /models 返回为准。默认推荐 group/auto(3AI Auto),按任务难易自动选模型。

curl

curl https://api.with3.ai/model/v1/chat/completions \
  -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -d '{"model":"group/auto","messages":[{"role":"user","content":"你好"}]}'

Python(openai SDK)

先安装:pip install openai。

from openai import OpenAI

client = OpenAI(api_key="<key>", base_url="https://api.with3.ai/model/v1")
response = client.chat.completions.create(
    model="group/auto",
    messages=[{"role": "user", "content": "你好"}],
)
print(response.choices[0].message.content)

错误码:401(key 缺失或无效)、403(这把 key 不能用该模型)、 429(限流)。

常见状态码

状态码含义
200成功(计费一次)
400参数错误(不扣费)
401未登录或钥匙无效
402余额不足
403未授权接口、已暂停,或该 Key 已达消耗限额(key_limit_exceeded)
404路径不存在
405请求方法不对
409相同的 Idempotency-Key 但参数不同,或同一请求仍在处理中
429频率超限(响应头 Retry-After 给出建议等待秒数,不扣费)
5xx服务不可用(不扣费)

接口文档 · 账户查看

具体开放接口与单价以文档页为准。

兼容地址

以下旧地址仍可用;新接入请使用正文中的地址。