SDK 下载与代码示例
官方 SDK 正在规划中。当前阶段建议先使用官网在线调试确认接口字段,正式开通后再由客户服务端使用 AppID / API Key 调用鲸海数据网关。
CLI 优先调用模板
所有接口文档都可以按下面的命令行结构交给 AI 代理执行。只需要替换 ENDPOINT 和参数变量。
JINGHAI_API_BASE="${JINGHAI_API_BASE:-https://www.kqdaas.com}"
JINGHAI_APP_ID="${JINGHAI_APP_ID:-YOUR_APP_ID}"
JINGHAI_API_KEY="${JINGHAI_API_KEY:-YOUR_API_KEY}"
COMPANY="成都乐云互动网络技术有限公司"
ENDPOINT="/DataService/api/v3/company/detail/${COMPANY}?queryType=1"
curl --fail-with-body --location --request GET "${JINGHAI_API_BASE}${ENDPOINT}" \
-H "X-Jinghai-App-Id: ${JINGHAI_APP_ID}" \
-H "X-Jinghai-Api-Key: ${JINGHAI_API_KEY}" \
-H "Accept: application/json"AI 代理执行提示词
你是命令行集成代理。请从环境变量读取 JINGHAI_API_BASE、JINGHAI_APP_ID、JINGHAI_API_KEY。
根据业务输入生成 ENDPOINT,使用 curl --fail-with-body --location 发起请求。
不要在日志、提交记录或前端代码中写入 API Key。
解析 JSON 响应:errcode/status/code 为 200 或 success=true 表示成功。
输出 data 字段;失败时输出状态码、message/errmsg/msg、requestId 和原始 ENDPOINT。Node.js / TypeScript 示例
// jinghai.js
const BASE = process.env.JINGHAI_API_BASE || "https://www.kqdaas.com";
const APP_ID = process.env.JINGHAI_APP_ID;
const API_KEY = process.env.JINGHAI_API_KEY;
export async function call(path, { method = "GET", body } = {}) {
const res = await fetch(`${BASE}${path}`, {
method,
headers: {
"X-Jinghai-App-Id": APP_ID,
"X-Jinghai-Api-Key": API_KEY,
"Content-Type": "application/json",
},
body: body ? JSON.stringify(body) : undefined,
});
const json = await res.json();
const code = json.errcode ?? json.status ?? json.code;
if (code !== 200 && json.success !== true) {
throw new Error(`[${code}] ${json.errmsg || json.message || json.msg}`);
}
return json.data;
}
const info = await call("/DataService/api/v3/company/detail/成都乐云互动网络技术有限公司?queryType=1");
console.log(info);Python 示例
import os
import requests
BASE = os.environ.get("JINGHAI_API_BASE", "https://www.kqdaas.com")
APP_ID = os.environ["JINGHAI_APP_ID"]
API_KEY = os.environ["JINGHAI_API_KEY"]
def call(path, method="GET", json_body=None, timeout=15):
res = requests.request(
method,
f"{BASE}{path}",
headers={
"X-Jinghai-App-Id": APP_ID,
"X-Jinghai-Api-Key": API_KEY,
"Content-Type": "application/json",
},
json=json_body,
timeout=timeout,
)
data = res.json()
code = data.get("errcode") or data.get("status") or data.get("code")
if code != 200 and data.get("success") is not True:
raise RuntimeError(f"[{code}] {data.get('errmsg') or data.get('message') or data.get('msg')}")
return data.get("data")
info = call("/DataService/api/v3/company/detail/成都乐云互动网络技术有限公司?queryType=1")
print(info)Java(OkHttp) 示例
import okhttp3.*;
public class JinghaiClient {
private final String base;
private final String appId;
private final String apiKey;
private final OkHttpClient client = new OkHttpClient();
public JinghaiClient(String base, String appId, String apiKey) {
this.base = base;
this.appId = appId;
this.apiKey = apiKey;
}
public String get(String path) throws Exception {
Request req = new Request.Builder()
.url(base + path)
.header("X-Jinghai-App-Id", appId)
.header("X-Jinghai-Api-Key", apiKey)
.get()
.build();
try (Response res = client.newCall(req).execute()) {
return res.body().string();
}
}
}接入建议
- 凭证只放服务端:不要写进前端代码、移动端安装包或公开仓库。
- 先在线调试:用官网数据市场确认参数、字段和返回结构。
- 统一错误处理:兼容
errcode、status、code三类状态字段。 - 记录调用日志:保留接口名、请求路径、状态码、耗时和
X-Jinghai-Request-Id。 - 失败重试:对
429、502、504做指数退避,避免无限重试。 - 按 0.05 元/次核算成本:免费额度用完后,正式开通接口按成功调用记录扣费或扣次数。
