@clarity.surf/sdk

中文文档
0.12.0发布于 2026/11/04SEE LICENSE IN LICENSETypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4万

Universal SDK for Clarity Search, Jobs, Indexing and News

原始使用文档

Clarity SDK

External clients use new ClarityClient({ apiKey }) with a scoped Oxy API key. API keys retain their external scopes and quotas even when issued for an Oxy app.

Own backend integrations use the shared workload transport:

import { clarityForOxyService } from '@clarity.surf/sdk/server';

const clarity = clarityForOxyService(oxyServer);
await clarity.search({ query: 'public information' });

oxyServer is the caller's existing OxyServer. The factory selects Clarity's recipient audience, oxy-service:01a0648b-8d73-70ad-8e67-1c07ddc5eb6e. Oxy owns workload attestation, bearer refresh, origin restrictions and retries. No key or scope list belongs in this integration.

Frontend integrations use the current provider's oxyServices:

import { clarityForOxySession } from '@clarity.surf/sdk';

const clarity = clarityForOxySession(oxyServices);
await clarity.experience.list(profileAccountId);
// On the owning component/client's disposal:
clarity.dispose();

The linked transport retains session switching and refresh. Do not read or copy http.getAccessToken() or wrap fetch with application-local Authorization logic. Personal Experience writes still require the authenticated account; workload identity does not select a person's account. Public and external client APIs remain available through ClarityClient.

The factories are source changes pending release. Deploy the matching Clarity receiver and Oxy authority API before adopting the service factory in callers.

Public reads need no credential at all. Discover's news is the same for every reader, so a screen with no reason to identify anyone (a photo frame, a kiosk) reads it with a client constructed with none:

import { ClarityClient } from '@clarity.surf/sdk';

const stories = await new ClarityClient().publicNews({ languages: ['es', 'en'], limit: 10 });
const [article] = stories[0]?.articles ?? [];
// article.imageUrl is Clarity's copy of the image; article.imageSeeds, once
// known, are its seed colours (`#rrggbb`, best first) to theme a card with.

版本与发布记录

@clarity.surf/sdk 共发布 15 个版本,首次发布于 2026/09/09;过去 12 个月发布了 15 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.12.0latest2026/11/045 天前
0.11.02026/10/3010 天前
0.10.02026/10/2417 天前
0.9.02026/10/1723 天前
0.8.02026/10/1723 天前
0.6.12026/10/1723 天前

关于 @clarity.surf/sdk 的常见问题

@clarity.surf/sdk 是什么?

Universal SDK for Clarity Search, Jobs, Indexing and News

如何安装 @clarity.surf/sdk?

在项目目录运行 npm install @clarity.surf/sdk,或使用 pnpm add / yarn add / bun add。

@clarity.surf/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clarity.surf/sdk 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@clarity.surf/sdk 可以商用吗?

@clarity.surf/sdk 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@clarity.surf/sdk 的下载量有多少?

根据 npm 官方下载统计,@clarity.surf/sdk 在 2026/10/10 – 2026/11/08 这 30 天内被下载 40,309 次,日均约 1,344 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@clarity.surf/sdk 还在维护吗?

最新版本 0.12.0 发布于 2026/11/04(5 天前);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/09/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。