FastComments.com

FastComments JavaScript/TypeScript 软件开发工具包


这是 FastComments 的官方 JavaScript/TypeScript SDK。

从 Node.js 或浏览器管理评论、用户、单点登录 (SSO) 和审核。

仓库

在 GitHub 上查看


安装 Internal Link

npm

npm install fastcomments-sdk

API 文档 Internal Link


完整的 API 参考: docs/api/README.md

浏览器与服务器兼容性 Internal Link


此 SDK 使用 双入口点 以确保最佳兼容性并防止运行时错误:

  • fastcomments-sdk/browser - 浏览器安全版本,使用原生 fetch
  • fastcomments-sdk/server - 完整的 Node.js 版本,支持 SSO
  • fastcomments-sdk (默认) - 仅类型,可在任何地方安全导入

公共与受保护的 API Internal Link

The SDK provides three main API classes:

  • DefaultApi - 受保护的端点,要求使用 API 密钥进行身份验证。用于服务器端操作。
  • PublicApi - 公共端点,可在无需 API 密钥的情况下访问。可以直接从浏览器/移动设备等调用。
  • HiddenApi - 用于高级用例的内部/管理端点。

Example: Using Public API (browser-safe)

import { PublicApi } from 'fastcomments-sdk/browser';

const publicApi = new PublicApi();

// 获取页面的评论(不需要 API 密钥)
const response = await publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id'
});

Example: Using Default API (server-side only)

import { DefaultApi, Configuration } from 'fastcomments-sdk/server';

const config = new Configuration({
  apiKey: 'your-api-key' // 请保密!
});
const defaultApi = new DefaultApi(config);

// 使用完整的管理员访问权限获取评论
const response = await defaultApi.getComments({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id'
});

SSO(单点登录)集成 Internal Link

FastComments 支持 SSO,以与您现有的用户认证系统集成。 SSO 功能仅在服务器导出中可用,因为它需要 Node.js crypto 功能。

简单 SSO(仅服务器端)

简单 SSO 应在服务器端生成并发送到客户端:

// 服务器端代码(Node.js/后端)
import { FastCommentsSSO, PublicApi } from 'fastcomments-sdk/server';

// 使用内置辅助创建简单 SSO  
const userData = {
  username: 'john_doe',
  email: 'john@example.com',
  displayName: 'John Doe',
  avatar: 'https://example.com/avatar.jpg'
};

const sso = FastCommentsSSO.createSimple(userData, {
  loginURL: '/login',
  logoutURL: '/logout'
});

const ssoToken = sso.createToken();

// 将 ssoToken 发送到您的客户端代码
// 客户端代码然后可以使用该令牌与浏览器 SDK 一起使用

安全 SSO(服务器端,推荐)

安全 SSO 应在服务器端实现,并提供更好的安全性:

// 服务器端代码(Node.js/后端)
import { FastCommentsSSO, PublicApi } from 'fastcomments-sdk/server';

// 使用内置辅助创建安全 SSO
const userData = {
  id: 'user-123',
  email: 'john@example.com',
  username: 'john_doe',
  displayName: 'John Doe',
  avatar: 'https://example.com/avatar.jpg',
  isAdmin: false,
  isModerator: false
};

const sso = FastCommentsSSO.createSecure('your-api-key', userData, {
  loginURL: '/login',
  logoutURL: '/logout'
});

const ssoConfig = sso.prepareToSend();

// 在服务器上与 API 调用一起使用
const publicApi = new PublicApi();
const response = await publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
  sso: JSON.stringify(ssoConfig)
});

// 或将 ssoConfig 发送到客户端以供浏览器使用

在浏览器中使用 SSO(使用服务器生成的令牌)

// 客户端代码(浏览器)
import { PublicApi } from 'fastcomments-sdk/browser';

// 从您的服务器端点获取 SSO 令牌
const ssoToken = await fetch('/api/sso-token').then(r => r.json());

const publicApi = new PublicApi();
const response = await publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
  sso: ssoToken // Use the server-generated SSO token
});

带评论创建的 SSO

// 服务器端:创建 SSO 和评论
import { FastCommentsSSO, PublicApi } from 'fastcomments-sdk/server';

const sso = FastCommentsSSO.createSecure('your-api-key', userData);
const ssoConfig = sso.prepareToSend();

const response = await publicApi.createCommentPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
  broadcastId: 'unique-broadcast-id',
  commentData: {
    comment: 'This is my comment',
    date: Date.now(),
    commenterName: 'John Doe',
    url: 'https://example.com/page',
    urlId: 'page-url-id'
  },
  sso: JSON.stringify(ssoConfig)
});

常见用例 Internal Link

获取页面的评论

const comments = await sdk.publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'article-123'
});

创建评论

const newComment = await sdk.publicApi.createCommentPublic({
  createCommentParams: {
    tenantId: 'your-tenant-id',
    urlId: 'article-123',
    comment: 'Great article!',
    commenterName: 'John Doe',
    commenterEmail: 'john@example.com'
  }
});

对评论投票

const voteResponse = await sdk.publicApi.voteComment({
  voteBodyParams: {
    commentId: 'comment-id',
    direction: 1 // 1 表示赞成,-1 表示反对
  }
});

用户管理(需要 API 密钥)

// 搜索用户(需要 DefaultApi)
const users = await sdk.defaultApi.searchUsers({
  tenantId: 'your-tenant-id',
  urlId: 'page-id',
  usernameStartsWith: 'john'
});

实时事件(实时更新) Internal Link

订阅实时事件以获取有关评论、投票和其他活动的实时更新。

页面级事件

监听特定页面的实时事件(评论、投票等):

import { subscribeToChanges, LiveEvent, LiveEventType } from 'fastcomments-sdk/browser';

const config = {
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
};

// Subscribe to live events for a page
const subscription = subscribeToChanges(
  config,
  'your-tenant-id', // tenantIdWS
  'page-url-id',    // urlIdWS  
  'user-session-id', // userIdWS (get this from getComments response)
  (event: LiveEvent) => {
    console.log('Live event received:', event);
    
    switch (event.type) {
      case LiveEventType.new_comment:
        console.log('New comment:', event.comment);
        // Update your UI with the new comment
        break;
      case LiveEventType.new_vote:
        console.log('New vote:', event.vote);
        // Update vote counts in your UI
        break;
      case LiveEventType.updated_comment:
        console.log('Comment updated:', event.comment);
        break;
      default:
        console.log('Other event type:', event.type);
    }
    
    return true; // Return true if event was handled
  },
  (isConnected: boolean) => {
    console.log('Connection status:', isConnected ? 'Connected' : 'Disconnected');
  }
);

// Close the subscription when done
subscription.close();

订阅用户事件

监听特定于用户的事件(通知、提及等):

import { subscribeToUserFeed, LiveEvent, LiveEventType } from 'fastcomments-sdk/browser';

const userConfig = {
  userIdWS: 'user-session-id', // Get this from getComments response
};

// Subscribe to user's personal feed
const userSubscription = subscribeToUserFeed(
  userConfig,
  (event: LiveEvent) => {
    console.log('User event received:', event);
    
    switch (event.type) {
      case LiveEventType.notification:
        console.log('New notification:', event.notification);
        // Show notification in your UI
        break;
      case LiveEventType.notification_update:
        console.log('Notification updated:', event.notification);
        break;
      default:
        console.log('Other user event:', event.type);
    }
    
    return true;
  },
  (isConnected: boolean) => {
    console.log('User feed connection:', isConnected ? 'Connected' : 'Disconnected');
  }
);

// Close when done
userSubscription.close();

获取 userIdWS

The userIdWS parameter is required for live events and can be obtained from API responses:

const response = await sdk.publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-id'
});

// Extract userIdWS from the response
const userIdWS = response.data?.userSessionInfo?.userIdWS;

if (userIdWS) {
  // Now you can subscribe to live events
  const subscription = subscribeToChanges(config, tenantIdWS, urlIdWS, userIdWS, handleEvent);
}

广播 ID Internal Link


您会看到在某些 API 调用中需要传递 broadcastId。当您接收事件时,会拿回这个 ID,这样如果您计划在客户端乐观地应用更改(您可能会想这样做,因为它提供了最佳体验),就可以知道是否忽略该事件。在这里传入一个 UUID。该 ID 应足够唯一,以避免在同一浏览器会话中出现两次。

import { v4 as uuidv4 } from 'uuid';

const response = await sdk.publicApi.createCommentPublic({
  createCommentParams: {
    tenantId: 'your-tenant-id',
    urlId: 'page-id',
    comment: 'My comment',
    broadcastId: uuidv4() // 此操作的唯一 ID
  }
});

错误处理 Internal Link

try {
  const comments = await sdk.publicApi.getCommentsPublic({
    tenantId: 'your-tenant-id',
    urlId: 'page-id'
  });
} catch (error) {
  if (error.response?.status === 404) {
    console.log('Page not found');
  } else {
    console.error('API Error:', error.message);
  }
}

聚合 Internal Link

通过对文档进行分组(如果提供了 groupBy)并应用多个操作来聚合文档。支持不同的操作(例如 sum、countDistinct、avg 等)。

参数

名称类型必需描述
tenantIdstring
aggregationRequestAggregationRequest
parentTenantIdstring
includeStatsboolean

响应

返回: Aggregate200Response

示例

aggregate 示例
Copy Copy
1
2const tenantId: string = 'tenant_78a9';
3const parentTenantId: string = 'parent_tenant_01';
4const includeStats: boolean = true;
5const aggregationRequest: AggregationRequest = {
6 operation: { type: 'COUNT' },
7 groupBy: ['pageUrl'],
8 predicate: { field: 'status', operator: 'EQUALS', value: 'approved' },
9 sort: [{ field: 'count', direction: 'DESC' }],
10 limit: 25
11};
12const result: Aggregate200Response = await aggregate(tenantId, aggregationRequest, parentTenantId, includeStats);
13

获取审计日志 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
limitnumber
skipnumber
orderSORTDIR
afternumber
beforenumber

响应

返回: GetAuditLogs200Response

示例

getAuditLogs 示例
Copy Copy
1
2const tenantId: string = 'tenant_5f8d7c3a';
3const limit: number = 100;
4const skip: number = 0;
5const order: SORTDIR = 'DESC' as SORTDIR;
6const after: number = Date.now() - 7 * 24 * 60 * 60 * 1000; // 一周前
7const before: number = Date.now();
8const result: GetAuditLogs200Response = await getAuditLogs(tenantId, limit, skip, order, after, before);
9

从评论中封锁(公共) Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
commentIdstring
publicBlockFromCommentParamsPublicBlockFromCommentParams
ssostring

响应

返回:BlockFromCommentPublic200Response

示例

blockFromCommentPublic 示例
Copy Copy
1
2const tenantId: string = 'tenant_6b3f9a2d';
3const commentId: string = 'cmt_8f4b12a9';
4const publicBlockFromCommentParams: PublicBlockFromCommentParams = {
5 reason: 'Repeated promotional links',
6 durationMinutes: 60 * 24 * 30, // 30 天
7 escalateToModeration: true
8};
9const sso: string = 'sso_token_3fH7kLw';
10
11const result: BlockFromCommentPublic200Response = await blockFromCommentPublic(tenantId, commentId, publicBlockFromCommentParams, sso);
12

解除对评论的封禁(公共) Internal Link

参数

名称类型是否必需描述
tenantIdstring
commentIdstring
publicBlockFromCommentParamsPublicBlockFromCommentParams
ssostring

响应

返回: UnBlockCommentPublic200Response

示例

unBlockCommentPublic 示例
Copy Copy
1
2const tenantId: string = "tenant-42-production";
3const commentId: string = "comment_7f3b2a9d";
4const publicBlockFromCommentParams: PublicBlockFromCommentParams = {
5 reason: "flag reviewed and determined not to violate policy",
6 restoredBy: "moderator_jane",
7 restoredAt: new Date().toISOString()
8};
9const sso: string = "sso_token_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
10const result: UnBlockCommentPublic200Response = await unBlockCommentPublic(tenantId, commentId, publicBlockFromCommentParams, sso);
11

检查被封禁的评论 Internal Link


参数

名称类型必需说明
tenantIdstring
commentIdsstring
ssostring

响应

返回:CheckedCommentsForBlocked200Response

示例

checkedCommentsForBlocked 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_fa3b2c9e';
4 const commentIds: string = 'cmt_112233,cmt_445566';
5 const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI0Njc4IiwidGVuYW50IjoidGVuYW50X2ZhM2IifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
6 const resultWithSSO: CheckedCommentsForBlocked200Response = await checkedCommentsForBlocked(tenantId, commentIds, sso);
7 const resultWithoutSSO: CheckedCommentsForBlocked200Response = await checkedCommentsForBlocked(tenantId, commentIds);
8 console.log(resultWithSSO, resultWithoutSSO);
9})();
10

从评论封禁用户 Internal Link

参数

名称类型必填描述
tenantIdstringYes
idstringYes
blockFromCommentParamsBlockFromCommentParamsYes
userIdstringNo
anonUserIdstringNo

响应

返回: BlockFromCommentPublic200Response

示例

blockUserFromComment 示例
Copy Copy
1
2const tenantId: string = "tenant_7f3b4c";
3const id: string = "comment_9a8b7c6d";
4const blockFromCommentParams: BlockFromCommentParams = {
5 reason: "Repeated spam links",
6 durationHours: 168,
7 notifyModerators: true
8};
9const userId: string | undefined = "user_42";
10const anonUserId: string | undefined = undefined;
11const result: BlockFromCommentPublic200Response = await blockUserFromComment(tenantId, id, blockFromCommentParams, userId, anonUserId);
12

创建评论(公共) Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
urlIdstring
broadcastIdstring
commentDataCommentData
sessionIdstring
ssostring

响应

返回: CreateCommentPublic200Response

示例

createCommentPublic 示例
Copy Copy
1
2const tenantId: string = 'tenant_9a1b2c';
3const urlId: string = 'https://www.news-site.com/article/67890';
4const broadcastId: string = 'broadcast_2026-06-15-01';
5const sessionId: string | undefined = 'sess_abc123xyz';
6const sso: string | undefined = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiam9yZGFuIiwiaWF0IjoxNjI0MDAwMDB9.signature';
7const commentData: CommentData = {
8 content: 'Insightful piece — I appreciated the data-backed points and sources cited.',
9 authorDisplayName: 'Jordan Miles'
10} as CommentData;
11const result: CreateCommentPublic200Response = await createCommentPublic(tenantId, urlId, broadcastId, commentData, sessionId, sso);
12

删除评论 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
contextUserIdstring
isLiveboolean

响应

返回: DeleteComment200Response

示例

deleteComment 示例
Copy Copy
1
2const tenantId: string = 'tenant_84a9f2';
3const id: string = 'comment_5f3b21';
4const contextUserId: string | undefined = 'user_1122';
5const isLive: boolean | undefined = true;
6
7async function run(): Promise<void> {
8 const result: DeleteComment200Response = await deleteComment(tenantId, id, contextUserId, isLive);
9 console.log(result);
10}
11
12run();
13

删除评论(公共) Internal Link

参数

Name类型必需描述
tenantIdstring
commentIdstring
broadcastIdstring
editKeystring
ssostring

响应

返回: DeleteCommentPublic200Response

示例

deleteCommentPublic 示例
Copy Copy
1
2const tenantId: string = 'tenant_acme_42';
3const commentId: string = 'c0mment-9f8b7a6';
4const broadcastId: string = 'site_homepage_2026-06-15';
5const editKey: string = 'ek_3b7a1f59-4d2c-11eb-8dcd-0242ac130003';
6const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.fakePayload.signature';
7
8const result: DeleteCommentPublic200Response = await deleteCommentPublic(tenantId, commentId, broadcastId, editKey, sso);
9

删除评论投票 Internal Link


参数

名称类型必需描述
tenantIdstring
commentIdstring
voteIdstring
urlIdstring
broadcastIdstring
editKeystring
ssostring

响应

返回: DeleteCommentVote200Response

示例

deleteCommentVote 示例
Copy Copy
1
2const tenantId: string = 'tenant_8f3a2b7c';
3const commentId: string = 'cmt-5a1f3d92';
4const voteId: string = 'vote-3b9c7e1a';
5const urlId: string = 'articles/2026/06/typescript-best-practices';
6const broadcastId: string = 'broadcast-77f4d2';
7const editKey: string = 'edk-9b2f4c';
8const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso_payload.signature';
9const result: DeleteCommentVote200Response = await deleteCommentVote(tenantId, commentId, voteId, urlId, broadcastId, editKey, sso);
10

举报评论 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring
userIdstring
anonUserIdstring

响应

返回:FlagComment200Response

示例

flagComment 示例
Copy Copy
1
2const tenantId: string = "tenant_4f21c9a";
3const commentId: string = "cmt_7a12b3e9";
4const userId: string = "user_82bd123";
5const result: FlagComment200Response = await flagComment(tenantId, commentId, userId);
6

获取评论 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring

响应

返回: GetComment200Response

示例

getComment 示例
Copy Copy
1
2const tenantId: string = 'tenant_6f1a2b';
3const commentId: string = 'cmt_4d9e8f';
4const includeReplies: boolean | undefined = true; // 可选参数示例(未传递给 getComment)
5const result: GetComment200Response = await getComment(tenantId, commentId);
6console.log('Fetched comment for tenant:', tenantId, 'comment id:', commentId);
7console.log('API response received:', result);
8

获取评论列表 Internal Link


参数

NameType必需Description
tenantIdstring
pagenumber
limitnumber
skipnumber
asTreeboolean
skipChildrennumber
limitChildrennumber
maxTreeDepthnumber
urlIdstring
userIdstring
anonUserIdstring
contextUserIdstring
hashTagstring
parentIdstring
directionSortDirections
fromDatenumber
toDatenumber

响应

返回: GetComments200Response

示例

getComments 示例
Copy Copy
1
2const tenantId: string = "tenant_9a12b3";
3const response: GetComments200Response = await getComments(tenantId, 1, 20, 0, true, 0, 3, 2, "https://mysite.com/posts/678", undefined, undefined, undefined, undefined, "parent_987", undefined, 1716873600000, 1719552000000);
4

获取评论(公共) Internal Link

req tenantId urlId

参数

名称类型必需描述
tenantIdstringYes
urlIdstringYes
pagenumberNo
directionSortDirectionsNo
ssostringNo
skipnumberNo
skipChildrennumberNo
limitnumberNo
limitChildrennumberNo
countChildrenbooleanNo
fetchPageForCommentIdstringNo
includeConfigbooleanNo
countAllbooleanNo
includei10nbooleanNo
localestringNo
modulesstringNo
isCrawlerbooleanNo
includeNotificationCountbooleanNo
asTreebooleanNo
maxTreeDepthnumberNo
useFullTranslationIdsbooleanNo
parentIdstringNo
searchTextstringNo
hashTagsArrayNo
userIdstringNo
customConfigStrstringNo
afterCommentIdstringNo
beforeCommentIdstringNo

响应

返回: GetCommentsPublic200Response

示例

getCommentsPublic 示例
Copy Copy
1
2const tenantId: string = 'acme-news';
3const urlId: string = '/articles/2026/fastcomments-update';
4const page: number = 1;
5const skip: number = 0;
6const limit: number = 25;
7const countChildren: boolean = true;
8const includeConfig: boolean = true;
9const result: GetCommentsPublic200Response = await getCommentsPublic(
10 tenantId,
11 urlId,
12 page,
13 undefined,
14 undefined,
15 skip,
16 undefined,
17 limit,
18 undefined,
19 countChildren,
20 undefined,
21 includeConfig
22);
23

获取评论文本 Internal Link

参数

名称类型必需描述
tenantIdstring
commentIdstring
editKeystring
ssostring

响应

返回:GetCommentText200Response

示例

getCommentText 示例
Copy Copy
1
2const tenantId: string = 'tenant_42b7e9';
3const commentId: string = 'cmt_9f3a2b';
4const editKey: string = 'edk_3f1b7c9d';
5const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ssoPayload.signature';
6
7const result: GetCommentText200Response = await getCommentText(tenantId, commentId, editKey, sso);
8

获取评论投票用户名 Internal Link

参数

名称类型必需描述
tenantIdstring
commentIdstring
dirnumber
ssostring

响应

返回: GetCommentVoteUserNames200Response

示例

getCommentVoteUserNames 示例
Copy Copy
1
2const tenantId: string = "tenant_67890";
3const commentId: string = "comment_abc123";
4const dir: number = 1;
5const ssoToken: string = "sso-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
6
7const responseWithoutSSO: GetCommentVoteUserNames200Response = await getCommentVoteUserNames(tenantId, commentId, dir);
8const responseWithSSO: GetCommentVoteUserNames200Response = await getCommentVoteUserNames(tenantId, commentId, dir, ssoToken);
9

锁定评论 Internal Link

参数

名称类型必需描述
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

响应

返回:LockComment200Response

示例

lockComment 示例
Copy Copy
1
2const tenantId: string = 'tenant_42f6c1';
3const commentId: string = 'cmt-9a8b7c';
4const broadcastId: string = 'brd_2026_06_15';
5const ssoToken: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1Njc4OSIsImlhdCI6MTY1MDAwMDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
6
7const lockedWithSso: LockComment200Response = await lockComment(tenantId, commentId, broadcastId, ssoToken);
8const lockedWithoutSso: LockComment200Response = await lockComment(tenantId, commentId, broadcastId);
9

置顶评论 Internal Link

参数

名称类型必需描述
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

响应

返回: PinComment200Response

示例

pinComment 示例
Copy Copy
1
2const tenantId: string = "acme-corp-tenant-72";
3const commentId: string = "cmt_8f3a2b4c9d";
4const broadcastId: string = "live_2026-06-15_21z";
5const ssoToken: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.fake.payload.signature";
6
7const responseNoSSO: PinComment200Response = await pinComment(tenantId, commentId, broadcastId);
8const responseWithSSO: PinComment200Response = await pinComment(tenantId, commentId, broadcastId, ssoToken);
9

保存评论 Internal Link

Parameters

NameTypeRequiredDescription
tenantIdstring
createCommentParamsCreateCommentParams
isLiveboolean
doSpamCheckboolean
sendEmailsboolean
populateNotificationsboolean

响应

返回: SaveComment200Response

示例

saveComment 示例
Copy Copy
1
2const tenantId: string = "fastcomments-tenant-42";
3const createCommentParams: CreateCommentParams = {
4 threadId: "article-2026-06-0142",
5 content: "Great write-up — I followed the migration steps and everything worked as described.",
6 userId: "u_9c72b",
7 userName: "Ava R.",
8 userAvatarUrl: "https://cdn.example.com/avatars/u_9c72b.png",
9 metadata: { platform: "web", locale: "en-US" }
10};
11const isLive: boolean = true;
12const doSpamCheck: boolean = true;
13const sendEmails: boolean = false;
14const populateNotifications: boolean = true;
15const result: SaveComment200Response = await saveComment(tenantId, createCommentParams, isLive, doSpamCheck, sendEmails, populateNotifications);
16

批量保存评论 Internal Link

参数

名称类型必需描述
tenantIdstring
createCommentParamsArray
isLiveboolean
doSpamCheckboolean
sendEmailsboolean
populateNotificationsboolean

响应

返回: Array<SaveComment200Response

示例

saveCommentsBulk 示例
Copy Copy
1
2const tenantId: string = "tenant_42a1b7";
3const mentions: CommentUserMentionInfo[] = [{ userId: "user_2b9", displayName: "Alex Chen" }];
4const hashtags: CommentUserHashTagInfo[] = [{ tag: "performance" }];
5const createCommentParams: CreateCommentParams[] = [
6 {
7 content: "Thanks for the detailed article — the alternative approach worked for me.",
8 authorId: "user_8f3c2",
9 authorName: "Maya Patel",
10 authorEmail: "maya.patel@example.com",
11 url: "/articles/optimizing-ts-performance",
12 createdAt: new Date().toISOString(),
13 mentions,
14 hashtags
15 }
16];
17const isLive: boolean = true;
18const doSpamCheck: boolean = false;
19const sendEmails: boolean = true;
20const populateNotifications: boolean = true;
21const result: Array<SaveComment200Response> = await saveCommentsBulk(tenantId, createCommentParams, isLive, doSpamCheck, sendEmails, populateNotifications);
22

设置评论文本 Internal Link

参数

名称类型必填描述
tenantIdstring
commentIdstring
broadcastIdstring
commentTextUpdateRequestCommentTextUpdateRequest
editKeystring
ssostring

响应

返回: SetCommentText200Response

示例

setCommentText 示例
Copy Copy
1
2const tenantId: string = 'tenant_4f9a2b'
3const commentId: string = 'cmt-8421'
4const broadcastId: string = 'brd-2026-06-15'
5const commentTextUpdateRequest: CommentTextUpdateRequest = { text: 'Updated comment text to clarify the schedule.', mentions: [], hashtags: [] }
6const editKey: string = 'editkey_9b12'
7const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso.signature'
8const result: SetCommentText200Response = await setCommentText(tenantId, commentId, broadcastId, commentTextUpdateRequest, editKey, sso)
9

解除对用户的评论封禁 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
unBlockFromCommentParamsUnBlockFromCommentParams
userIdstring
anonUserIdstring

响应

返回: UnBlockCommentPublic200Response

示例

unBlockUserFromComment 示例
Copy Copy
1
2const tenantId: string = 'tenant_7b9c2a';
3const id: string = 'comment_4f8e1d';
4const unBlockFromCommentParams: UnBlockFromCommentParams = {
5 reason: 'User submitted appeal and provided additional context',
6 effectiveAt: new Date().toISOString()
7};
8const userId: string = 'user_92a3f6';
9const result: UnBlockCommentPublic200Response = await unBlockUserFromComment(tenantId, id, unBlockFromCommentParams, userId);
10

取消举报评论 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
userIdstring
anonUserIdstring

响应

返回: FlagComment200Response

示例

unFlagComment 示例
Copy Copy
1
2const tenantId: string = 'tenant_8f3b2a1f';
3const commentId: string = 'cmt_20250614_01';
4const userId: string = 'user_47d2b9';
5const result: FlagComment200Response = await unFlagComment(tenantId, commentId, userId);
6

解锁评论 Internal Link

参数

名称Type必需描述
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

响应

返回: LockComment200Response

示例

unLockComment 示例
Copy Copy
1
2const tenantId: string = "tenant-8f3b2c4a";
3const commentId: string = "cmt_92a7f3e6";
4const broadcastId: string = "brd_1b4c9d20";
5const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMTIzIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
6const result: LockComment200Response = await unLockComment(tenantId, commentId, broadcastId, sso);
7

取消置顶评论 Internal Link


参数

名称类型必填描述
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

响应

返回: PinComment200Response

示例

unPinComment 示例
Copy Copy
1
2const tenantId: string = "tenant_9f3b2c1a";
3const commentId: string = "comment_4d2e8a7f";
4const broadcastId: string = "broadcast_live_2026_06_15_18";
5const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.invalid-signature";
6const response: PinComment200Response = await unPinComment(tenantId, commentId, broadcastId, sso);
7console.log(response);
8

更新评论 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updatableCommentParamsUpdatableCommentParams
contextUserIdstring
doSpamCheckboolean
isLiveboolean

响应

返回:FlagCommentPublic200Response

示例

updateComment 示例
Copy Copy
1
2const tenantId: string = 'tenant_7f3c1b2a';
3const commentId: string = 'cmt_8d9f2a4b';
4const updatableCommentParams: UpdatableCommentParams = {
5 body: 'Updating this comment to clarify the feature behavior and include a timestamp.',
6 metadata: { category: 'support', editedReason: 'clarify instructions' },
7 visible: true
8};
9const contextUserId: string = 'user_42';
10const doSpamCheck: boolean = true;
11const result: FlagCommentPublic200Response = await updateComment(tenantId, commentId, updatableCommentParams, contextUserId, doSpamCheck);
12

对评论投票 Internal Link

参数

名称类型必填描述
tenantIdstring
commentIdstring
urlIdstring
broadcastIdstring
voteBodyParamsVoteBodyParams
sessionIdstring
ssostring

响应

返回: VoteComment200Response

示例

voteComment 示例
Copy Copy
1
2const tenantId: string = 'tenant_7f9d2e';
3const commentId: string = '5a1d3f9b-2c4e-4a2b-bf7b-1234567890ab';
4const urlId: string = 'articles/2026/06/15/typescript-api-patterns';
5const broadcastId: string = 'broadcast-20260615-01';
6const voteBodyParams: VoteBodyParams = { vote: 'up' };
7const sessionId: string = 'sess_9d2f3b45';
8const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzEyMyIsImlhdCI6MTY5NzE2MDAwMH0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
9
10const response: VoteComment200Response = await voteComment(
11 tenantId,
12 commentId,
13 urlId,
14 broadcastId,
15 voteBodyParams,
16 sessionId,
17 sso
18);
19

获取用户的评论 Internal Link

参数

名称类型必填描述
userIdstring
directionSortDirections
repliesToUserIdstring
pagenumber
includei10nboolean
localestring
isCrawlerboolean

响应

返回:GetCommentsForUser200Response

示例

getCommentsForUser 示例
Copy Copy
1
2const userId: string = "550e8400-e29b-41d4-a716-446655440000";
3const page: number = 2;
4const includei10n: boolean = true;
5const locale: string = "en-US";
6const isCrawler: boolean = false;
7
8const comments: GetCommentsForUser200Response = await getCommentsForUser(
9 userId,
10 undefined, // direction omitted
11 undefined, // repliesToUserId omitted
12 page,
13 includei10n,
14 locale,
15 isCrawler
16);
17
18console.log(comments);
19

添加域配置 Internal Link


参数

名称类型必需说明
tenantIdstring
addDomainConfigParamsAddDomainConfigParams

响应

返回: AddDomainConfig200Response


删除域配置 Internal Link

参数

名称类型必填描述
tenantIdstring
domainstring

响应

返回: DeleteDomainConfig200Response


获取域配置 Internal Link

参数

名称类型必填描述
tenantIdstring
domainstring

响应

返回: GetDomainConfig200Response


获取域配置列表 Internal Link


参数

名称类型必需描述
tenantIdstring

响应

返回: GetDomainConfigs200Response


部分更新域配置 Internal Link

参数

名称类型必需描述
tenantIdstring
domainToUpdatestring
patchDomainConfigParamsPatchDomainConfigParams

响应

返回: GetDomainConfig200Response


替换域配置 Internal Link


参数

名称类型必填描述
tenantIdstring
domainToUpdatestring
updateDomainConfigParamsUpdateDomainConfigParams

响应

返回: GetDomainConfig200Response


创建邮件模板 Internal Link

参数

名称类型必需描述
tenantIdstring
createEmailTemplateBodyCreateEmailTemplateBody

响应

返回: CreateEmailTemplate200Response

示例

createEmailTemplate 示例
Copy Copy
1
2const tenantId: string = "tenant_4f2b1c9e";
3const createEmailTemplateBody: CreateEmailTemplateBody = {
4 name: "New Comment Notification",
5 subject: "Someone replied to your discussion",
6 fromName: "Community Team",
7 fromAddress: "no-reply@community.example.com",
8 htmlBody: "<p>\{{comment.author}} replied: \{{comment.text}}</p>",
9 plaintextBody: "\{{comment.author}} replied: \{{comment.text}}",
10 previewText: "A new reply on a discussion you follow",
11 isDefault: false // 可选标志,演示可选参数的用法
12};
13const result: CreateEmailTemplate200Response = await createEmailTemplate(tenantId, createEmailTemplateBody);
14

删除邮件模板 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: FlagCommentPublic200Response

示例

deleteEmailTemplate 示例
Copy Copy
1
2const tenantId: string = "tenant_9c4f1b2a";
3const id: string = "emailtmpl_4d2b9a5e";
4const requestorNote: string | undefined = undefined; // 可选元数据(函数不需要)
5const result: FlagCommentPublic200Response = await deleteEmailTemplate(tenantId, id);
6

删除邮件模板渲染错误 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
errorIdstring

响应

返回: FlagCommentPublic200Response

示例

deleteEmailTemplateRenderError 示例
Copy Copy
1
2const tenantId: string = 'tenant-72f3b4';
3const templateId: string = 'email_template-9c3a1';
4let providedErrorId: string | undefined = undefined; // 可选值,可能在其他地方设置
5const errorId: string = providedErrorId ?? 'render_err-5d2f7';
6const result: FlagCommentPublic200Response = await deleteEmailTemplateRenderError(tenantId, templateId, errorId);
7

获取邮件模板 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring

响应

返回:GetEmailTemplate200Response

示例

getEmailTemplate 示例
Copy Copy
1
2const tenantId: string = 'tenant_7f3b2c';
3const templateId: string = 'welcome-email-2024';
4const includeDrafts: boolean | undefined = undefined;
5const emailTemplate: GetEmailTemplate200Response = await getEmailTemplate(tenantId, templateId);
6

获取邮件模板定义 Internal Link


参数

名称类型必需描述
tenantIdstring

响应

返回: GetEmailTemplateDefinitions200Response

示例

getEmailTemplateDefinitions 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_acme_001';
4 const options: { includeDrafts?: boolean } = { includeDrafts: true }; // 演示可选参数
5 const templates: GetEmailTemplateDefinitions200Response = await getEmailTemplateDefinitions(tenantId, options);
6 console.log(templates);
7})();
8

获取邮件模板渲染错误 Internal Link

参数

名称类型必需描述
tenantIdstringYes
idstringYes
skipnumberNo

响应

返回: GetEmailTemplateRenderErrors200Response

示例

getEmailTemplateRenderErrors 示例
Copy Copy
1
2const tenantId: string = 'acme-tenant-01';
3const id: string = 'tmpl_7f9a2b4c';
4const skip: number = 20;
5
6const errorsWithSkip: GetEmailTemplateRenderErrors200Response = await getEmailTemplateRenderErrors(tenantId, id, skip);
7const errorsFirstPage: GetEmailTemplateRenderErrors200Response = await getEmailTemplateRenderErrors(tenantId, id);
8

获取邮件模板列表 Internal Link

参数

名称类型必填描述
tenantIdstring
skipnumber

响应

返回:GetEmailTemplates200Response

示例

getEmailTemplates 示例
Copy Copy
1
2async function run(): Promise<void> {
3 const tenantId: string = "acme-marketing-tenant-001";
4 const templatesDefault: GetEmailTemplates200Response = await getEmailTemplates(tenantId);
5 const templatesPaged: GetEmailTemplates200Response = await getEmailTemplates(tenantId, 25);
6 console.log(templatesDefault, templatesPaged);
7}
8run();
9

渲染邮件模板 Internal Link


参数

名称类型必填描述
tenantIdstring
renderEmailTemplateBodyRenderEmailTemplateBody
localestring

响应

返回: RenderEmailTemplate200Response

示例

renderEmailTemplate 示例
Copy Copy
1
2const tenantId: string = '7f7e2b90-3a2b-4d9b-9df1-5f0b6b2e8a1c';
3const renderEmailTemplateBody: RenderEmailTemplateBody = {
4 templateId: 'welcome_email',
5 recipient: { email: 'jordan.smith@acme.co', name: 'Jordan Smith' },
6 variables: { siteName: 'Acme Forum', verificationUrl: 'https://acme.forum/verify?code=abc123' }
7};
8const locale: string = 'en-US';
9const result: RenderEmailTemplate200Response = await renderEmailTemplate(tenantId, renderEmailTemplateBody, locale);
10

更新邮件模板 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
updateEmailTemplateBodyUpdateEmailTemplateBody

响应

返回: FlagCommentPublic200Response

示例

updateEmailTemplate 示例
Copy Copy
1
2const tenantId: string = 'acme-corp-123';
3const id: string = 'template-789';
4const locale: string | undefined = 'en-US';
5const updateEmailTemplateBody: UpdateEmailTemplateBody = {
6 subject: 'Welcome to Acme — Get started',
7 bodyHtml: '<p>Hi \{{firstName}}, welcome to Acme. Start by visiting your dashboard.</p>',
8 fromName: 'Acme Support',
9 fromEmail: 'support@acme.com',
10 enabled: true,
11 ...(locale ? { locale } : {})
12};
13const result: FlagCommentPublic200Response = await updateEmailTemplate(tenantId, id, updateEmailTemplateBody);
14

获取事件日志 Internal Link

req tenantId urlId userIdWS

参数

NameTypeRequiredDescription
tenantIdstring
urlIdstring
userIdWSstring
startTimenumber
endTimenumber

响应

返回: GetEventLog200Response

示例

getEventLog 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f3a2b';
3const urlId: string = 'news/2026/06/fastcomments-release';
4const userIdWS: string = 'ws_user_48291';
5const startTime: number = Date.now() - 86_400_000;
6const endTime: number = Date.now();
7const result: GetEventLog200Response = await getEventLog(tenantId, urlId, userIdWS, startTime, endTime);
8

获取全局事件日志 Internal Link

req tenantId urlId userIdWS

参数

名称类型必需描述
tenantIdstring
urlIdstring
userIdWSstring
startTimenumber
endTimenumber

响应

返回: GetEventLog200Response

示例

getGlobalEventLog 示例
Copy Copy
1
2const tenantId: string = "tenant_639b7f12";
3const urlId: string = "https://www.news-site.com/articles/2026/06/15/important-update-987";
4const userIdWS: string = "user_ws_42b7";
5const startTime: number = new Date("2026-06-14T00:00:00Z").getTime();
6const endTime: number = Date.now();
7
8const eventLog: GetEventLog200Response = await getGlobalEventLog(tenantId, urlId, userIdWS, startTime, endTime);
9

创建动态帖子 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
createFeedPostParamsCreateFeedPostParams
broadcastIdstring
isLiveboolean
doSpamCheckboolean
skipDupCheckboolean

响应

返回:CreateFeedPost200Response

示例

createFeedPost 示例
Copy Copy
1
2const tenantId: string = 'tenant_4f2b1c';
3const createFeedPostParams: CreateFeedPostParams = {
4 content: 'Launching our summer collection today — check it out!',
5 authorId: 'user_879',
6 media: [
7 {
8 type: 'image',
9 assets: [
10 { url: 'https://cdn.myshop.com/uploads/summer-look.jpg', width: 1200, height: 800 } as FeedPostMediaItemAsset
11 ]
12 } as FeedPostMediaItem
13 ],
14 links: [
15 { url: 'https://myshop.com/new-arrival', title: 'Summer Collection' } as FeedPostLink
16 ],
17 allowComments: true
18};
19const broadcastId: string = 'broadcast-2026-06-15-001';
20const isLive: boolean = false;
21const doSpamCheck: boolean = true;
22const skipDupCheck: boolean = false;
23const response: CreateFeedPost200Response = await createFeedPost(tenantId, createFeedPostParams, broadcastId, isLive, doSpamCheck, skipDupCheck);
24

创建动态帖子(公共) Internal Link

参数

名称类型必需描述
tenantIdstring
createFeedPostParamsCreateFeedPostParams
broadcastIdstringNo
ssostring

响应

返回: CreateFeedPostPublic200Response

示例

createFeedPostPublic 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = "tenant_9f8b7c";
4 const media: FeedPostMediaItem[] = [{ type: "image", assets: [{ url: "https://cdn.example.com/roadmap.jpg", mimeType: "image/jpeg" }] }];
5 const links: FeedPostLink[] = [{ url: "https://company.example.com/roadmap", title: "Full roadmap" }];
6 const createFeedPostParams: CreateFeedPostParams = {
7 title: "Weekly Product Roadmap Update",
8 body: "This week we shipped enhancements to search relevance and fixed top customer bugs.",
9 authorId: "user_8321",
10 media,
11 links,
12 visibility: "public"
13 };
14 const broadcastId: string = "broadcast_2026_06_15";
15 const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso_payload";
16 const response: CreateFeedPostPublic200Response = await createFeedPostPublic(tenantId, createFeedPostParams, broadcastId, sso);
17 console.log(response);
18})();
19

删除动态帖子(公共) Internal Link

参数

名称类型必需描述
tenantIdstring
postIdstring
broadcastIdstring
ssostring

响应

返回:DeleteFeedPostPublic200Response

示例

deleteFeedPostPublic 示例
Copy Copy
1
2const tenantId: string = 'acme-tenant-42';
3const postId: string = 'post_8f3d2a7c';
4const broadcastId: string = 'broadcast_2026-06-15_01';
5const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ssoPayload.signature';
6const response: DeleteFeedPostPublic200Response = await deleteFeedPostPublic(tenantId, postId, broadcastId, sso);
7

获取动态帖子 Internal Link


req tenantId afterId

参数

名称类型必需描述
tenantIdstring
afterIdstring
limitnumber
tagsArray

响应

返回: GetFeedPosts200Response

示例

getFeedPosts 示例
Copy Copy
1
2const tenantId: string = "tenant_74321";
3const afterId: string = "post_20250610_9b2f3";
4const limit: number = 25;
5const tags: Array<string> = ["product-updates", "announcements"];
6
7const response: GetFeedPosts200Response = await getFeedPosts(tenantId, afterId, limit, tags);
8

获取动态帖子(公共) Internal Link

req tenantId afterId

参数

名称类型必填描述
tenantIdstring
afterIdstring
limitnumber
tagsArray
ssostring
isCrawlerboolean
includeUserInfoboolean

响应

返回:GetFeedPostsPublic200Response

示例

getFeedPostsPublic 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_acme_01';
4 const afterId: string = 'post_20250610_842';
5 const limit: number = 25;
6 const tags: string[] = ['news', 'technology'];
7 const sso: string = 'sso_jwt_eyJhbGciOiJIUzI1Ni';
8 const isCrawler: boolean = false;
9 const includeUserInfo: boolean = true;
10
11 const response: GetFeedPostsPublic200Response = await getFeedPostsPublic(
12 tenantId,
13 afterId,
14 limit,
15 tags,
16 sso,
17 isCrawler,
18 includeUserInfo
19 );
20
21 console.log(response);
22})();
23

获取动态帖子统计 Internal Link

参数

NameTypeRequiredDescription
tenantIdstringYes
postIdsArrayYes
ssostringNo

响应

返回: GetFeedPostsStats200Response

示例

getFeedPostsStats 示例
Copy Copy
1
2const tenantId: string = "tenant_98765";
3const postIds: string[] = ["post_a1b2c3", "post_d4e5f6"];
4const ssoToken: string = "sso_jwt_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
5
6const statsWithoutSSO: GetFeedPostsStats200Response = await getFeedPostsStats(tenantId, postIds);
7const statsWithSSO: GetFeedPostsStats200Response = await getFeedPostsStats(tenantId, postIds, ssoToken);
8

获取用户反应(公共) Internal Link

参数

名称类型必需描述
tenantIdstring
postIdsArray
ssostring

响应

返回:GetUserReactsPublic200Response

示例

getUserReactsPublic 示例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-4f2b9c';
3const postIds: Array<string> = ['post_7a1f9e', 'post_2b3c88'];
4const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1Njc4OSIsImlhdCI6MTYwOTQ0MDAwMH0.signature';
5
6const response: GetUserReactsPublic200Response = await getUserReactsPublic(tenantId, postIds, sso);
7

对动态帖子做出反应(公共) Internal Link

参数

名称类型必填描述
tenantIdstring
postIdstring
reactBodyParamsReactBodyParams
isUndoboolean
broadcastIdstring
ssostring

响应

返回: ReactFeedPostPublic200Response

示例

reactFeedPostPublic 示例
Copy Copy
1
2const tenantId: string = 'acme-tenant-001';
3const postId: string = 'feedpost_78901';
4const reactBodyParams: ReactBodyParams = { reaction: 'like', emoji: '👍' };
5const isUndo: boolean = false;
6const broadcastId: string = 'broadcast_2026_06_15_01';
7const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.signature';
8
9const response: ReactFeedPostPublic200Response = await reactFeedPostPublic(
10 tenantId,
11 postId,
12 reactBodyParams,
13 isUndo,
14 broadcastId,
15 sso
16);
17

更新动态帖子 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring
feedPostFeedPost

响应

返回:FlagCommentPublic200Response

示例

updateFeedPost 示例
Copy Copy
1
2const tenantId: string = "tenant_72f3b4c9";
3const id: string = "post_ba4f6e18-2d3c-4b7a-91f2-8c0e3a6b5d4f";
4
5const feedPost: FeedPost = {
6 title: "June feature rollout",
7 body: "Announcing performance improvements and moderation updates available to all sites.",
8 authorName: "Platform Team",
9 mediaItems: [
10 {
11 type: "image",
12 caption: "Release banner",
13 asset: { url: "https://cdn.fastcomments.com/assets/june-banner.jpg", mimeType: "image/jpeg", width: 1200, height: 600 }
14 }
15 ],
16 links: [{ title: "Release notes", url: "https://docs.fastcomments.com/releases/june-2026" }]
17} as FeedPost;
18
19const result: FlagCommentPublic200Response = await updateFeedPost(tenantId, id, feedPost);
20

更新动态帖子(公共) Internal Link

参数

名称类型必需描述
tenantIdstring
postIdstring
updateFeedPostParamsUpdateFeedPostParams
broadcastIdstring
ssostring

响应

返回: CreateFeedPostPublic200Response

示例

updateFeedPostPublic 示例
Copy Copy
1
2const tenantId: string = 'tenant_acme_01';
3const postId: string = 'post_20260615_001';
4const updateFeedPostParams: UpdateFeedPostParams = {
5 title: 'Weekly Update: Product Launch',
6 content: 'We shipped the 2.0 release today — highlights and links below.',
7 media: [{ url: 'https://cdn.acme.com/releases/launch.jpg', type: 'image' }],
8 tags: ['release', 'product'],
9 isPublic: true
10};
11const broadcastId: string = 'broadcast_live_42';
12const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9';
13const result: CreateFeedPostPublic200Response = await updateFeedPostPublic(tenantId, postId, updateFeedPostParams, broadcastId, sso);
14

举报评论(公共) Internal Link

参数

名称类型必填描述
tenantIdstring
commentIdstring
isFlaggedboolean
ssostring

响应

返回: FlagCommentPublic200Response

示例

flagCommentPublic 示例
Copy Copy
1
2const tenantId: string = "tenant_4f1b2a9c";
3const commentId: string = "comment_8d3e6f12";
4const isFlagged: boolean = true;
5const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
6const result: FlagCommentPublic200Response = await flagCommentPublic(tenantId, commentId, isFlagged, sso);
7

获取大动图 Internal Link

参数

名称类型必填描述
tenantIdstring
largeInternalURLSanitizedstring

响应

返回: GetGifLarge200Response

示例

getGifLarge 示例
Copy Copy
1
2const tenantId: string = "tenant_9f8b7c";
3const largeInternalURLSanitized: string = "https://cdn.fastcomments.com/gifs/07d3f6_large.gif";
4const preferWebP: boolean | undefined = true; // 可选偏好
5const urlToUse: string = preferWebP ? largeInternalURLSanitized.replace(".gif", ".webp") : largeInternalURLSanitized;
6const response: GetGifLarge200Response = await getGifLarge(tenantId, urlToUse);
7

搜索动图 Internal Link

参数

名称类型必填描述
tenantIdstring
searchstring
localestring
ratingstring
pagenumber

Response

返回: GetGifsSearch200Response

示例

getGifsSearch 示例
Copy Copy
1
2const tenantId: string = "tenant_acme_9876";
3const search: string = "cat playing piano";
4const locale: string = "en-US";
5const rating: string = "pg";
6const page: number = 1;
7const result: GetGifsSearch200Response = await getGifsSearch(tenantId, search, locale, rating, page);
8

获取流行动图 Internal Link

参数

名称类型必填描述
tenantIdstring
localestring
ratingstring
pagenumber

响应

返回: GetGifsTrending200Response

示例

getGifsTrending 示例
Copy Copy
1
2async function main(): Promise<void> {
3 const tenantId: string = 'tenant_8b3f2c';
4 const locale: string = 'en-US';
5 const rating: string = 'pg';
6 const page: number = 1;
7 const result: GetGifsTrending200Response = await getGifsTrending(tenantId, locale, rating, page);
8 console.log(result);
9}
10main();
11

添加标签 Internal Link

参数

名称类型必填描述
tenantIdstring
createHashTagBodyCreateHashTagBody

响应

返回: AddHashTag200Response

示例

addHashTag 示例
Copy Copy
1
2const tenantId: string | undefined = "tenant_3c9f7b";
3const createHashTagBody: CreateHashTagBody = {
4 name: "support",
5 title: "Support",
6 description: "Questions about product usage, bugs, and account issues",
7 color: "#0066CC",
8 isActive: true,
9 aliases: ["help", "customer-service"]
10};
11const result: AddHashTag200Response = await addHashTag(tenantId, createHashTagBody);
12

批量添加标签 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
bulkCreateHashTagsBodyBulkCreateHashTagsBody

响应

返回:AddHashTagsBulk200Response

示例

addHashTagsBulk 示例
Copy Copy
1
2const tenantId: string = "tenant_acme_corp_987";
3const bulkCreateHashTagsBody: BulkCreateHashTagsBody = {
4 tags: [
5 { name: "product-update", description: "Announcements about new product releases", visible: true },
6 { name: "customer-support", description: "Customer support related discussions", visible: false }
7 ],
8 createdBy: "moderator_jane"
9};
10const resultWithTenant: AddHashTagsBulk200Response = await addHashTagsBulk(tenantId, bulkCreateHashTagsBody);
11const resultWithoutTenant: AddHashTagsBulk200Response = await addHashTagsBulk(undefined, bulkCreateHashTagsBody);
12

删除标签 Internal Link

参数

名称类型必需描述
tagstring
tenantIdstring
deleteHashTagRequestDeleteHashTagRequest

响应

返回: FlagCommentPublic200Response

示例

deleteHashTag 示例
Copy Copy
1
2const tag: string = "breaking-news";
3const tenantId: string = "tenant_72a1";
4const deleteHashTagRequest: DeleteHashTagRequest = {
5 reason: "consolidate-duplicates",
6 requestedBy: "moderator@dailypress.com",
7 forceDelete: true
8};
9const result: FlagCommentPublic200Response = await deleteHashTag(tag, tenantId, deleteHashTagRequest);
10

获取标签 Internal Link

参数

名称类型必需描述
tenantIdstring
pagenumber

响应

返回:GetHashTags200Response

示例

getHashTags 示例
Copy Copy
1
2const tenantId: string = 'tenant_7f4b2c3a';
3const tagsFirstPage: GetHashTags200Response = await getHashTags(tenantId);
4const tagsSecondPage: GetHashTags200Response = await getHashTags(tenantId, 2);
5console.log(tagsFirstPage, tagsSecondPage);
6

部分更新标签 Internal Link


参数

NameTypeRequiredDescription
tagstring
tenantIdstring
updateHashTagBodyUpdateHashTagBody

响应

返回:PatchHashTag200Response

示例

patchHashTag 示例
Copy Copy
1
2const tag: string = "feature-request";
3const tenantId: string = "tenant_8f7a3b2c";
4const updateHashTagBody: UpdateHashTagBody = {
5 displayName: "Feature Request",
6 description: "Use this tag for requests to add new features to the product",
7 enabled: true
8};
9const result: PatchHashTag200Response = await patchHashTag(tag, tenantId, updateHashTagBody);
10

创建版主 Internal Link

参数

名称类型必填描述
tenantIdstring
createModeratorBodyCreateModeratorBody

响应

返回: CreateModerator200Response

示例

createModerator 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b21';
3const createModeratorBody: CreateModeratorBody = {
4 moderator: {
5 name: 'Alex Rivera',
6 email: 'alex.rivera@fastcomments.io',
7 role: 'global_moderator',
8 enabled: true,
9 },
10 // 演示可选参数:
11 notifyUser: true,
12 permissions: ['delete_comment', 'edit_comment', 'ban_user'],
13 customConfig: { dashboardTheme: 'dark' } as unknown as CustomConfigParameters
14};
15const result: CreateModerator200Response = await createModerator(tenantId, createModeratorBody);
16

删除版主 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
sendEmailstring

响应

返回: FlagCommentPublic200Response

示例

deleteModerator 示例
Copy Copy
1
2const tenantId: string = 'tenant_4f3b2c9a';
3const id: string = 'mod_9c2d1f7b';
4const sendEmail: string = 'true';
5const response: FlagCommentPublic200Response = await deleteModerator(tenantId, id, sendEmail);
6console.log(response);
7

获取版主 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: GetModerator200Response

示例

getModerator 示例
Copy Copy
1
2const tenantId: string = 'acme-media-58';
3const id: string = 'mod-82f3b9c1';
4const moderatorResponse: GetModerator200Response = await getModerator(tenantId, id);
5

获取版主列表 Internal Link

参数

名称类型必需描述
tenantIdstring
skipnumber

响应

返回: GetModerators200Response

示例

getModerators 示例
Copy Copy
1
2const tenantId: string = 'tenant_0a1b2c3d';
3const moderators: GetModerators200Response = await getModerators(tenantId);
4const skip: number = 20;
5const moderatorsPage2: GetModerators200Response = await getModerators(tenantId, skip);
6

发送邀请 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
fromNamestring

返回

返回:FlagCommentPublic200Response

示例

sendInvite 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = "tenant_acme_42";
4 const id: string = "cmt_8f3b21";
5 const fromName: string = "Ava Thompson";
6 const inviteResult: FlagCommentPublic200Response = await sendInvite(tenantId, id, fromName);
7 console.log(inviteResult);
8})();
9

更新版主 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updateModeratorBodyUpdateModeratorBody

响应

返回: FlagCommentPublic200Response

示例

updateModerator 示例
Copy Copy
1
2const tenantId: string = 'acme-tenant-81';
3const id: string = 'mod_7f3a2b';
4const updateModeratorBody: UpdateModeratorBody = {
5 email: 'j.reyes@acme-corp.com',
6 displayName: 'Jordan Reyes',
7 roles: ['moderator', 'content_reviewer'],
8 active: true,
9 notes: 'Promoted to senior moderator; monitor flagged content weekly'
10};
11const result: FlagCommentPublic200Response = await updateModerator(tenantId, id, updateModeratorBody);
12

删除通知计数 Internal Link


参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: FlagCommentPublic200Response

示例

deleteNotificationCount 示例
Copy Copy
1
2const tenantId: string = 'tenant_5f3d2e1b';
3const id: string = 'notification_9a4b1c2';
4const result: FlagCommentPublic200Response = await deleteNotificationCount(tenantId, id);
5

获取缓存的通知计数 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring

响应

返回:GetCachedNotificationCount200Response

示例

getCachedNotificationCount 示例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-23';
3const id: string = 'user_987654';
4const cachedCount: GetCachedNotificationCount200Response = await getCachedNotificationCount(tenantId, id);
5
6const maybeId: string | undefined = Math.random() > 0.5 ? 'user_123456' : undefined;
7if (maybeId) {
8 const optionalCachedCount: GetCachedNotificationCount200Response = await getCachedNotificationCount(tenantId, maybeId);
9}
10

获取通知计数 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
userIdstring
urlIdstring
fromCommentIdstring
viewedboolean
typestring

响应

返回:GetNotificationCount200Response

示例

getNotificationCount 示例
Copy Copy
1
2const tenantId: string = 'tenant_82a3b9f';
3const userId: string = 'user_43721';
4const urlId: string = 'https://news.example.com/articles/2026/06/15/coverage-123';
5const fromCommentId: string = 'comment_98765';
6const viewed: boolean = false;
7const notificationType: string = 'mention';
8
9const result: GetNotificationCount200Response = await getNotificationCount(tenantId, userId, urlId, fromCommentId, viewed, notificationType);
10

获取通知 Internal Link

参数

名称类型必需描述
tenantIdstring
userIdstring
urlIdstring
fromCommentIdstring
viewedboolean
typestring
skipnumber

响应

返回: GetNotifications200Response

示例

getNotifications 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f8b7c6a';
3const userId: string = 'user_5a4b3c2d';
4const urlId: string = 'post_84f2a1b9';
5const fromCommentId: string = 'cmt_0a1b2c3d';
6const viewed: boolean = false;
7const type: string = 'reply';
8const skip: number = 0;
9
10const notifications: GetNotifications200Response = await getNotifications(
11 tenantId,
12 userId,
13 urlId,
14 fromCommentId,
15 viewed,
16 type,
17 skip
18);
19

更新通知 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring
updateNotificationBodyUpdateNotificationBody
userIdstring

响应

返回:FlagCommentPublic200Response

示例

updateNotification 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2c';
3const id: string = 'notification_4a1d2e';
4const updateNotificationBody: UpdateNotificationBody = {
5 enabled: true,
6 channels: ['email', 'push'],
7 frequency: 'immediate',
8 templateId: 'tmpl_77aa'
9} as UpdateNotificationBody;
10const userId: string = 'user_2468';
11const result: FlagCommentPublic200Response = await updateNotification(tenantId, id, updateNotificationBody, userId);
12

创建 V1 页面反应 Internal Link


参数

名称类型必填描述
tenantIdstring
urlIdstring
titlestring

响应

返回: CreateV1PageReact200Response

示例

createV1PageReact 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'b12f3c4d-5678-90ab-cdef-1234567890ab';
4 const urlId: string = 'https://www.news-site.com/world/2026/election-results';
5 const title: string = 'Election results: key takeaways and analysis';
6 const responseWithTitle: CreateV1PageReact200Response = await createV1PageReact(tenantId, urlId, title);
7 const responseWithoutTitle: CreateV1PageReact200Response = await createV1PageReact(tenantId, urlId);
8 console.log(responseWithTitle, responseWithoutTitle);
9})();
10

创建 V2 页面反应 Internal Link

参数

名称类型必需描述
tenantIdstring
urlIdstring
idstring
titlestring

响应

返回: CreateV2PageReact200Response

示例

createV2PageReact 示例
Copy Copy
1
2const tenantId: string = "fastcomments-tenant-72";
3const urlId: string = "articles/2026/06/15/product-update";
4const id: string = "page-8f3b2a";
5const title: string = "Product Update: June 15, 2026";
6
7(async function run(): Promise<void> {
8 const response: CreateV2PageReact200Response = await createV2PageReact(tenantId, urlId, id, title);
9 console.log(response);
10})();
11

删除 V1 页面反应 Internal Link

参数

名称类型必需描述
tenantIdstring
urlIdstring

返回

返回: DeleteV1PageReact200Response

示例

deleteV1PageReact 示例
Copy Copy
1
2const tenantId: string = process.env.TENANT_ID ?? 'd3b07384-9f6a-4c2b-8c3e-0a1b2c3d4e5f';
3const urlId: string = 'https://acme.com/articles/2026/06/fastcomments-integration';
4const result: DeleteV1PageReact200Response = await deleteV1PageReact(tenantId, urlId);
5

删除 V2 页面反应 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
urlIdstring
idstring

响应

返回: DeleteV2PageReact200Response

示例

deleteV2PageReact 示例
Copy Copy
1
2const tenantId: string = "tenant_79021";
3const urlId: string = "blog/my-first-post";
4const id: string = "reaction_9f8b7c";
5let includeHistory: boolean | undefined = undefined; // 可选标志,在某些调用中使用
6
7const result: DeleteV2PageReact200Response = await deleteV2PageReact(tenantId, urlId, id);
8console.log(result);
9

获取 V1 页面点赞 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
urlIdstring

响应

返回: GetV1PageLikes200Response

示例

getV1PageLikes 示例
Copy Copy
1
2const tenantId: string = 'fastcomments-742';
3const urlId: string = 'sports/2026/06/15/world-cup-preview';
4const pageLikes: GetV1PageLikes200Response = await getV1PageLikes(tenantId, urlId);
5

获取 V2 页面反应 Internal Link

参数

名称类型必需描述
tenantIdstring
urlIdstring

响应

返回: GetV2PageReacts200Response

示例

getV2PageReacts 示例
Copy Copy
1
2const tenantId: string = "tenant_82f4b3a9";
3const urlId: string = "https://news.site.com/articles/2026/06/15/product-launch";
4const response: GetV2PageReacts200Response = await getV2PageReacts(tenantId, urlId);
5console.log(response);
6

获取 V2 页面反应用户 Internal Link

参数

名称类型必需描述
tenantIdstring
urlIdstring
idstring

Response

返回: GetV2PageReactUsers200Response

示例

getV2PageReactUsers 示例
Copy Copy
1
2const tenantId: string = "7421";
3const urlId: string = "sports/london-marathon";
4const id: string = "reactUser-3fa85f64-5717-4562-b3fc-2c963f66afa6";
5const includeDeleted: boolean | undefined = undefined; // 可选标志(示例)
6
7const result: GetV2PageReactUsers200Response = await getV2PageReactUsers(tenantId, urlId, id);
8

添加页面 Internal Link


参数

名称类型必填描述
tenantIdstring
createAPIPageDataCreateAPIPageData

响应

返回: AddPageAPIResponse


删除页面 Internal Link


参数

名称类型必需描述
tenantIdstring
idstring

响应

返回: DeletePageAPIResponse


获取离线用户 Internal Link

页面上之前评论但当前不在线的用户。按 displayName 排序。 在耗尽 /users/online 后使用此方法以渲染“成员”部分。 对 commenterName 进行游标分页:服务器沿部分 {tenantId, urlId, commenterName} 索引,从 afterName 向前通过 $gt 遍历,无需 $skip 成本。

参数

名称类型必需描述
tenantIdstring
urlIdstring
afterNamestring
afterUserIdstring

响应

返回: GetOfflineUsers200Response

示例

getOfflineUsers 示例
Copy Copy
1
2const tenantId: string = 'tenant_prod_001';
3const urlId: string = 'article-2026-06-15-how-ai-impacts';
4const afterName: string = 'michael.smith';
5const afterUserId: string = 'user_72b9';
6
7const response: GetOfflineUsers200Response = await getOfflineUsers(tenantId, urlId, afterName, afterUserId);
8

获取在线用户 Internal Link


当前页面的在线查看者:当前其 websocket 会话已订阅该页面的人。 返回 anonCount + totalCount(房间范围的订阅者,包括我们不列举的匿名查看者)。

参数

名称类型必需描述
tenantIdstring
urlIdstring
afterNamestring
afterUserIdstring

响应

返回:GetOnlineUsers200Response

示例

getOnlineUsers 示例
Copy Copy
1
2const tenantId: string = 'tenant_14f9c3';
3const urlId: string = 'article_20250615';
4const afterName: string = 'marie.curie';
5const afterUserId: string = 'u_92b7';
6const result: GetOnlineUsers200Response = await getOnlineUsers(tenantId, urlId, afterName, afterUserId);
7

通过 URL ID 获取页面 Internal Link

参数

名称类型必需描述
tenantIdstring
urlIdstring

响应

返回:GetPageByURLIdAPIResponse


获取页面列表 Internal Link

参数

名称类型必填描述
tenantIdstring

响应

返回: GetPagesAPIResponse


获取页面(公共) Internal Link

列出租户的页面。由 FChat 桌面客户端用于填充其房间列表。 要求在每个页面的解析后的自定义配置中 enableFChat 为 true。 需要 SSO 的页面会根据请求用户的组访问权限进行过滤。

Parameters

名称类型必需描述
tenantIdstringYes
cursorstringNo
limitnumberNo
qstringNo
sortByPagesSortByNo
hasCommentsbooleanNo

Response

返回: GetPagesPublic200Response

Example

getPagesPublic 示例
Copy Copy
1
2const tenantId: string = 'tenant_8f3b2c';
3const cursor: string = 'eyJwYWdlIjoiMTIwIn0';
4const limit: number = 25;
5const q: string = 'homepage hero';
6const hasComments: boolean = true;
7
8const response: GetPagesPublic200Response = await getPagesPublic(
9 tenantId,
10 cursor,
11 limit,
12 q,
13 undefined,
14 hasComments
15);
16

获取用户信息 Internal Link

为租户批量获取用户信息。给定 userIds,返回 User / SSOUser 的展示信息。 由评论小部件使用,用于丰富那些通过在线状态事件刚刚出现的用户信息。 无页面上下文:隐私统一强制执行(私人档案将被屏蔽)。

参数

NameTypeRequiredDescription
tenantIdstring
idsstring

响应

返回:GetUsersInfo200Response

示例

getUsersInfo 示例
Copy Copy
1
2const tenantId: string = 'acme-tenant-007';
3const userIdsList: string[] = ['user_12a', 'user_34b', 'user_56c'];
4const separator: string | undefined = undefined; // 可选;如果为 undefined 则默认使用逗号
5const ids: string = userIdsList.join(separator ?? ',');
6const usersInfo: GetUsersInfo200Response = await getUsersInfo(tenantId, ids);
7

部分更新页面 Internal Link


参数

名称类型必需描述
tenantIdstring
idstring
updateAPIPageDataUpdateAPIPageData

响应

返回: PatchPageAPIResponse


删除待处理的 Webhook 事件 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring

响应

返回: FlagCommentPublic200Response

示例

deletePendingWebhookEvent 示例
Copy Copy
1
2const tenantId: string = "tenant_5f8d7a34";
3const id: string = "webhook_evt_987654321";
4const requestNote: string | undefined = undefined;
5const response: FlagCommentPublic200Response = await deletePendingWebhookEvent(tenantId, id);
6

获取待处理 Webhook 事件计数 Internal Link

参数

名称类型必填描述
tenantIdstring
commentIdstring
externalIdstring
eventTypestring
typestring
domainstring
attemptCountGTnumber

响应

返回: GetPendingWebhookEventCount200Response

示例

getPendingWebhookEventCount 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f8b3b';
3const commentId: string = 'cmt_1a2b3c';
4const eventType: string = 'comment.created';
5const domain: string = 'news-site.com';
6const attemptCountGT: number = 2;
7
8const result: GetPendingWebhookEventCount200Response = await getPendingWebhookEventCount(
9 tenantId,
10 commentId,
11 undefined, // externalId omitted
12 eventType,
13 undefined, // type omitted
14 domain,
15 attemptCountGT
16);
17

获取待处理的 Webhook 事件 Internal Link

参数

名称类型必填描述
tenantIdstring
commentIdstring
externalIdstring
eventTypestring
typestring
domainstring
attemptCountGTnumber
skipnumber

响应

返回:GetPendingWebhookEvents200Response

示例

getPendingWebhookEvents 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2a';
3const commentId: string = 'cmt_8a7d1';
4const eventType: string = 'comment.created';
5const domain: string = 'reviews.myshop.com';
6const attemptCountGT: number = 1;
7const skip: number = 0;
8
9const result: GetPendingWebhookEvents200Response = await getPendingWebhookEvents(
10 tenantId,
11 commentId,
12 undefined,
13 eventType,
14 undefined,
15 domain,
16 attemptCountGT,
17 skip
18);
19

创建问题配置 Internal Link

参数

名称类型必需描述
tenantIdstringYes
createQuestionConfigBodyCreateQuestionConfigBodyYes

响应

返回: CreateQuestionConfig200Response

示例

createQuestionConfig 示例
Copy Copy
1
2const tenantId: string = "tenant_9f3b1c2a";
3
4const createQuestionConfigBody: CreateQuestionConfigBody = {
5 name: "Product feedback",
6 key: "product_quality",
7 description: "Short survey question shown after posting a comment",
8 required: true,
9 renderingType: "singleChoice",
10 customOptions: [
11 { label: "Excellent", value: "5" },
12 { label: "Good", value: "4" },
13 { label: "Fair", value: "3" }
14 ] as QuestionConfigCustomOptionsInner[],
15 notifyModerators: false // 演示可选参数
16};
17
18const result: CreateQuestionConfig200Response = await createQuestionConfig(tenantId, createQuestionConfigBody);
19

删除问题配置 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: FlagCommentPublic200Response

示例

deleteQuestionConfig 示例
Copy Copy
1
2const tenantId: string = 'acme-corp-47a9';
3const id: string = 'qcfg_20260615_001';
4const result: FlagCommentPublic200Response = await deleteQuestionConfig(tenantId, id);
5

获取问题配置 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring

响应

返回: GetQuestionConfig200Response

示例

getQuestionConfig 示例
Copy Copy
1
2const tenantId: string = "acme-corp-47";
3const questionId: string = "q-4f2b9a";
4const includeDrafts: boolean | undefined = undefined; // 可选参数占位符
5const result: GetQuestionConfig200Response = await getQuestionConfig(tenantId, questionId);
6console.log(result);
7

获取问题配置列表 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
skipnumber

响应

返回: GetQuestionConfigs200Response

示例

getQuestionConfigs 示例
Copy Copy
1
2const tenantId: string = "tenant_4c9f2b";
3const responseWithoutSkip: GetQuestionConfigs200Response = await getQuestionConfigs(tenantId);
4const skip: number = 50;
5const responseWithSkip: GetQuestionConfigs200Response = await getQuestionConfigs(tenantId, skip);
6

更新问题配置 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updateQuestionConfigBodyUpdateQuestionConfigBody

响应

返回: FlagCommentPublic200Response

示例

updateQuestionConfig 示例
Copy Copy
1
2const tenantId: string = "tenant_9f3b8a2e-4c6d-4b4f-a1b2-9e8f7d6c5b3a";
3const id: string = "q_7c2e1b4a-5d6f-4a8b-9c3d-2e1f0b9a4c5d";
4const options: QuestionConfigCustomOptionsInner[] = [
5 { value: "1", label: "Very dissatisfied" },
6 { value: "2", label: "Dissatisfied" },
7 { value: "3", label: "Neutral" },
8 { value: "4", label: "Satisfied" },
9 { value: "5", label: "Very satisfied" }
10];
11const updateQuestionConfigBody: UpdateQuestionConfigBody = {
12 label: "How satisfied are you with the article?",
13 enabled: true,
14 required: false, // 演示可选参数
15 options
16};
17const result: FlagCommentPublic200Response = await updateQuestionConfig(tenantId, id, updateQuestionConfigBody);
18

创建问题结果 Internal Link

参数

名称类型必填描述
tenantIdstring
createQuestionResultBodyCreateQuestionResultBody

响应

返回: CreateQuestionResult200Response

示例

createQuestionResult 示例
Copy Copy
1
2const tenantId: string = 'fc-tenant-512';
3const meta: MetaItem[] = [{ key: 'source', value: 'article' }];
4const body: CreateQuestionResultBody = {
5 questionId: 'q-94',
6 userId: 'user_332',
7 answers: [{ optionId: 'opt_a', score: 1 }],
8 meta, // 提供的可选元数据
9} as CreateQuestionResultBody;
10const result: CreateQuestionResult200Response = await createQuestionResult(tenantId, body);
11

删除问题结果 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回:FlagCommentPublic200Response

示例

deleteQuestionResult 示例
Copy Copy
1
2const tenantId: string = "acme-corp-tenant-01";
3const id: string = "qres_9f8b7c3a";
4const response: FlagCommentPublic200Response = await deleteQuestionResult(tenantId, id);
5const optionalResponse: FlagCommentPublic200Response | undefined = response;
6

获取问题结果 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring

响应

返回: GetQuestionResult200Response

示例

getQuestionResult 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2a7c9';
3const questionId: string = 'q_8d4f1b2c3a';
4const options: { includeMeta?: boolean } = { includeMeta: true }; // 可选参数示例
5const result: GetQuestionResult200Response = await getQuestionResult(tenantId, questionId);
6const apiStatus: APIStatus | undefined = (result as unknown as { apiStatus?: APIStatus }).apiStatus;
7const question: QuestionResult | undefined = (result as unknown as { question?: QuestionResult }).question;
8

获取问题结果列表 Internal Link

参数

名称类型必填描述
tenantIdstring
urlIdstring
userIdstring
startDatestring
questionIdstring
questionIdsstring
skipnumber

响应

返回: GetQuestionResults200Response

示例

getQuestionResults 示例
Copy Copy
1
2const tenantId: string = 'fc-tenant-7a9c';
3const urlId: string = 'news/article-2026-06-15';
4const userId: string = 'user-8421';
5const startDate: string = '2026-05-01T00:00:00Z';
6const questionId: string = 'q-13';
7const questionIds: string = 'q-13,q-14';
8const skip: number = 20;
9const result: GetQuestionResults200Response = await getQuestionResults(tenantId, urlId, userId, startDate, questionId, questionIds, skip);
10

更新问题结果 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring
updateQuestionResultBodyUpdateQuestionResultBody

响应

返回: FlagCommentPublic200Response

示例

updateQuestionResult 示例
Copy Copy
1
2const tenantId: string = "tenant_prod_84b2";
3const id: string = "question_9f3a";
4const updateQuestionResultBody: UpdateQuestionResultBody = {
5 outcome: "accepted",
6 confidence: 0.88,
7 moderatorId: "moderator_17",
8 notes: "Validated by automated review" // 包含可选字段
9};
10const result: FlagCommentPublic200Response = await updateQuestionResult(tenantId, id, updateQuestionResultBody);
11

聚合问题结果 Internal Link


参数

名称类型必需描述
tenantIdstring
questionIdstring
questionIdsArray
urlIdstring
timeBucketAggregateTimeBucket
startDateDate
forceRecalculateboolean

响应

返回: AggregateQuestionResults200Response

示例

aggregateQuestionResults 示例
Copy Copy
1
2const tenantId: string = 'tenant_6f2b3c';
3const questionIds: Array<string> = ['q-7a1b2c', 'q-8d3e4f'];
4const urlId: string = 'url_9f8e7d';
5const startDate: Date = new Date('2025-01-01T00:00:00Z');
6const result: AggregateQuestionResults200Response = await aggregateQuestionResults(tenantId, undefined, questionIds, urlId, undefined, startDate, true);
7

批量聚合问题结果 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
bulkAggregateQuestionResultsRequestBulkAggregateQuestionResultsRequest
forceRecalculateboolean

响应

返回: BulkAggregateQuestionResults200Response

示例

bulkAggregateQuestionResults 示例
Copy Copy
1
2const tenantId: string = "tenant_0012";
3const bulkAggregateQuestionResultsRequest: BulkAggregateQuestionResultsRequest = {
4 items: [
5 {
6 questionId: "quality_score",
7 startTime: "2026-06-01T00:00:00Z",
8 endTime: "2026-06-14T00:00:00Z",
9 timeBucket: "day",
10 dimensions: ["threadId"]
11 }
12 ],
13 includeTotals: true
14};
15const forceRecalculate: boolean = false;
16const result: BulkAggregateQuestionResults200Response = await bulkAggregateQuestionResults(tenantId, bulkAggregateQuestionResultsRequest, forceRecalculate);
17

将评论与问题结果合并 Internal Link

参数

名称类型必需描述
tenantIdstringYes
questionIdstringNo
questionIdsArrayNo
urlIdstringNo
startDateDateNo
forceRecalculatebooleanNo
minValuenumberNo
maxValuenumberNo
limitnumberNo

响应

返回: CombineCommentsWithQuestionResults200Response

示例

combineCommentsWithQuestionResults 示例
Copy Copy
1
2const tenantId: string = 'tenant_12345';
3const questionId: string = 'q_98765';
4const questionIds: string[] = ['q_98765', 'q_12345'];
5const urlId: string = 'url_abc123';
6const startDate: Date = new Date('2026-01-01T00:00:00Z');
7const forceRecalculate: boolean = true;
8const minValue: number = 0;
9const maxValue: number = 5;
10const limit: number = 50;
11const result: CombineCommentsWithQuestionResults200Response = await combineCommentsWithQuestionResults(
12 tenantId,
13 questionId,
14 questionIds,
15 urlId,
16 startDate,
17 forceRecalculate,
18 minValue,
19 maxValue,
20 limit
21);
22

添加 SSO 用户 Internal Link

参数

名称类型必需描述
tenantIdstring
createAPISSOUserDataCreateAPISSOUserData

响应

返回: AddSSOUserAPIResponse

删除 SSO 用户 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
deleteCommentsboolean
commentDeleteModestring

响应

返回: DeleteSSOUserAPIResponse


通过邮箱获取 SSO 用户 Internal Link


参数

名称类型必需描述
tenantIdstring
emailstring

响应

返回: GetSSOUserByEmailAPIResponse


通过 ID 获取 SSO 用户 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: GetSSOUserByIdAPIResponse


获取 SSO 用户列表 Internal Link

参数

名称类型必填描述
tenantIdstring
skipnumber

响应

返回: GetSSOUsers200Response


部分更新 SSO 用户 Internal Link


参数

名称类型必填描述
tenantIdstring
idstring
updateAPISSOUserDataUpdateAPISSOUserData
updateCommentsboolean

响应

返回:PatchSSOUserAPIResponse


替换 SSO 用户 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updateAPISSOUserDataUpdateAPISSOUserData
updateCommentsboolean

响应

返回: PutSSOUserAPIResponse

示例

putSSOUser 示例
Copy Copy
1
2const tenantId: string = 'acme-enterprises-42';
3const id: string = 'usr-73a1b2';
4const updateAPISSOUserData: UpdateAPISSOUserData = {
5 email: 'marcus.ingram@acme.com',
6 givenName: 'Marcus',
7 familyName: 'Ingram',
8 roles: ['editor', 'project_owner'],
9 enabled: true
10};
11const result: PutSSOUserAPIResponse = await putSSOUser(tenantId, id, updateAPISSOUserData, true);
12

创建订阅 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
createAPIUserSubscriptionDataCreateAPIUserSubscriptionData

响应

返回:CreateSubscriptionAPIResponse

示例

createSubscription 示例
Copy Copy
1
2const tenantId: string = "acme-corp-tenant-123";
3const createAPIUserSubscriptionData: CreateAPIUserSubscriptionData = {
4 userId: "user_98765",
5 planId: "pro_monthly",
6 paymentMethod: { type: "card", cardId: "card_abc123" },
7 autoRenew: true,
8 trialDays: 14, // 演示可选参数
9 metadata: { campaign: "spring_launch" } // 演示可选参数
10};
11const result: CreateSubscriptionAPIResponse = await createSubscription(tenantId, createAPIUserSubscriptionData);
12

删除订阅 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
userIdstring

响应

返回: DeleteSubscriptionAPIResponse


获取订阅 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
userIdstring

响应

返回: GetSubscriptionsAPIResponse

示例

getSubscriptions 示例
Copy Copy
1
2const tenantId: string = "contoso-9a1b2c";
3const userId: string = "u-482f6";
4const subscriptions: GetSubscriptionsAPIResponse = await getSubscriptions(tenantId);
5const userSubscriptions: GetSubscriptionsAPIResponse = await getSubscriptions(tenantId, userId);
6

更新订阅 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
updateAPIUserSubscriptionDataUpdateAPIUserSubscriptionData
userIdstring

响应

返回: UpdateSubscriptionAPIResponse

示例

updateSubscription 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2c';
3const subscriptionId: string = 'sub_7641a2b3';
4const updateData: UpdateAPIUserSubscriptionData = {
5 status: 'active',
6 planId: 'pro_annual',
7 autoRenew: true,
8 renewalDate: '2026-04-15T00:00:00Z',
9 metadata: { upgradedBy: 'billing-team' }
10};
11const userId: string = 'user_215';
12const result: UpdateSubscriptionAPIResponse = await updateSubscription(tenantId, subscriptionId, updateData, userId);
13

获取租户每日使用情况 Internal Link

参数

名称类型必需描述
tenantIdstring
yearNumbernumber
monthNumbernumber
dayNumbernumber
skipnumber

响应

返回: GetTenantDailyUsages200Response

示例

getTenantDailyUsages 示例
Copy Copy
1
2const tenantId: string = 'tenant_7a3c2e';
3const dailyUsages: GetTenantDailyUsages200Response = await getTenantDailyUsages(tenantId, 2026, 6, undefined, 0);
4

创建租户套餐 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
createTenantPackageBodyCreateTenantPackageBody

响应

返回: CreateTenantPackage200Response

示例

createTenantPackage 示例
Copy Copy
1
2const tenantId: string = "tenant_7890";
3const createTenantPackageBody: CreateTenantPackageBody = {
4 packageName: "Growth Plan",
5 maxSeats: 2500,
6 features: {
7 moderation: true,
8 analytics: true,
9 sso: { enabled: true, provider: "saml" }
10 },
11 billing: { interval: "monthly", priceCents: 19900 },
12 // 示例可选参数:notes 非必填,但已提供
13 notes: "Onboarding bundle with priority support"
14};
15const result: CreateTenantPackage200Response = await createTenantPackage(tenantId, createTenantPackageBody);
16

删除租户套餐 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring

响应

返回: FlagCommentPublic200Response

示例

deleteTenantPackage 示例
Copy Copy
1
2const tenantId: string = 'acme-corp-tenant-01';
3const packageId: string = 'pkg-2026-06-15-001';
4const dryRun: boolean | undefined = undefined; // 可选标志示例(函数不要求)
5const result: FlagCommentPublic200Response = await deleteTenantPackage(tenantId, packageId);
6

获取租户套餐 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring

响应

返回: GetTenantPackage200Response

示例

getTenantPackage 示例
Copy Copy
1
2const tenantId: string = 'tenant_4b8c2a9f';
3const packageId: string = 'pkg_7d3e1b5c';
4const includeMetadata: boolean | undefined = true;
5const packageResponse: GetTenantPackage200Response = await getTenantPackage(tenantId, packageId);
6

获取租户套餐列表 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
skipnumber

响应

返回: GetTenantPackages200Response

示例

getTenantPackages 示例
Copy Copy
1
2const tenantId: string = 'tenant_8421';
3const packagesWithSkip: GetTenantPackages200Response = await getTenantPackages(tenantId, 25);
4const packagesWithoutSkip: GetTenantPackages200Response = await getTenantPackages(tenantId);
5

替换租户套餐 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
replaceTenantPackageBodyReplaceTenantPackageBody

响应

返回: FlagCommentPublic200Response

示例

replaceTenantPackage 示例
Copy Copy
1
2const tenantId: string = "fastcomments-tenant-114";
3const id: string = "pkg-enterprise-2026-06";
4const replaceTenantPackageBody: ReplaceTenantPackageBody = {
5 name: "EnterpriseModeration",
6 version: "2.4.7",
7 enabled: true,
8 apiStatus: { state: "active", lastUpdated: "2026-06-10T12:00:00Z" },
9 customConfigParameters: { maxCommentLength: 1200, allowImages: true }, // 包含可选设置
10 voteStyle: { style: "updown" }
11};
12const result: FlagCommentPublic200Response = await replaceTenantPackage(tenantId, id, replaceTenantPackageBody);
13

更新租户套餐 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updateTenantPackageBodyUpdateTenantPackageBody

响应

返回: FlagCommentPublic200Response

示例

updateTenantPackage 示例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2a';
3const id: string = 'pkg_pro_2026';
4const updateTenantPackageBody: UpdateTenantPackageBody = {
5 name: 'Pro Plan',
6 monthlyPriceUsd: 49,
7 isActive: true,
8 features: ['moderation', 'analytics', 'sso'],
9 trialDays: 14 // 可选参数示例
10};
11const result: FlagCommentPublic200Response = await updateTenantPackage(tenantId, id, updateTenantPackageBody);
12

创建租户用户 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
createTenantUserBodyCreateTenantUserBody

响应

返回: CreateTenantUser200Response

示例

createTenantUser 示例
Copy Copy
1
2const tenantId: string = "tenant_7f4a2b";
3const createTenantUserBody: CreateTenantUserBody = {
4 email: "jane.doe@example.com",
5 firstName: "Jane",
6 lastName: "Doe",
7 role: "commenter",
8 approved: true,
9 displayName: "Jane D." // 可选:提供一个友好的显示名称
10};
11const result: CreateTenantUser200Response = await createTenantUser(tenantId, createTenantUserBody);
12console.log(result);
13

删除租户用户 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
deleteCommentsstring
commentDeleteModestring

响应

返回: FlagCommentPublic200Response

示例

deleteTenantUser 示例
Copy Copy
1
2const tenantId: string = "tenant_8f3a2b1c4d";
3const id: string = "user_62a4f9e0b7";
4const deleteComments: string = "true";
5const commentDeleteMode: string = "permanent";
6const result: FlagCommentPublic200Response = await deleteTenantUser(tenantId, id, deleteComments, commentDeleteMode);
7

获取租户用户 Internal Link


参数

名称类型必需描述
tenantIdstring
idstring

响应

返回: GetTenantUser200Response

示例

getTenantUser 示例
Copy Copy
1
2const tenantId: string = 'tenant_ab12c3';
3const id: string = 'user_9f8e7d';
4const response: GetTenantUser200Response = await getTenantUser(tenantId, id);
5console.log(response);
6

获取租户用户列表 Internal Link

参数

名称类型必需描述
tenantIdstring
skipnumber

响应

返回:GetTenantUsers200Response

示例

getTenantUsers 示例
Copy Copy
1
2const tenantId: string = 'tenant_7b8f3a2c-9e4d-4f1a';
3const skip: number = 50;
4const usersResponseDefault: GetTenantUsers200Response = await getTenantUsers(tenantId);
5const usersResponsePaged: GetTenantUsers200Response = await getTenantUsers(tenantId, skip);
6

替换租户用户 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
replaceTenantUserBodyReplaceTenantUserBody
updateCommentsstring

响应

返回:FlagCommentPublic200Response

示例

replaceTenantUser 示例
Copy Copy
1
2const tenantId: string = "f3b9a2d1-8b4e-4c6a-9f2b-1d5c4e6a7b8c";
3const id: string = "user_92f7c3b1";
4const replaceTenantUserBody: ReplaceTenantUserBody = {
5 externalId: "auth0|1234567890",
6 email: "jane.doe@company.com",
7 displayName: "Jane Doe",
8 roles: ["moderator"],
9 metadata: { department: "support" }
10};
11const updateComments: string = "reassign-comments-to-new-user";
12const response: FlagCommentPublic200Response = await replaceTenantUser(tenantId, id, replaceTenantUserBody, updateComments);
13

参数

NameTypeRequiredDescription
tenantIdstring
idstring
redirectURLstring

响应

返回: FlagCommentPublic200Response

示例

sendLoginLink 示例
Copy Copy
1
2const tenantId: string = "tenant_0a1b2c3d";
3const id: string = "user_984321";
4const redirectURL: string = "https://app.acme-corp.com/welcome";
5const responseWithRedirect: FlagCommentPublic200Response = await sendLoginLink(tenantId, id, redirectURL);
6const responseWithoutRedirect: FlagCommentPublic200Response = await sendLoginLink(tenantId, id);
7

更新租户用户 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updateTenantUserBodyUpdateTenantUserBody
updateCommentsstring

响应

返回: FlagCommentPublic200Response

示例

updateTenantUser 示例
Copy Copy
1
2const tenantId: string = 'acme-corp';
3const userId: string = 'u_72b9f4';
4const updateTenantUserBody: UpdateTenantUserBody = {
5 email: 'jane.doe@acme.com',
6 displayName: 'Jane Doe',
7 roles: ['moderator'],
8 suspended: false
9};
10const updateComments: string = 'Promoted to moderator after review of activity and community feedback';
11const result: FlagCommentPublic200Response = await updateTenantUser(tenantId, userId, updateTenantUserBody, updateComments);
12

创建租户 Internal Link

参数

名称类型必填描述
tenantIdstring
createTenantBodyCreateTenantBody

响应

返回: CreateTenant200Response

示例

createTenant 示例
Copy Copy
1
2const tenantId: string = 'acme-news-01';
3const createTenantBody: CreateTenantBody = {
4 name: 'Acme News',
5 domainConfiguration: { primaryDomain: 'news.acme.com', redirectHttps: true } as APIDomainConfiguration,
6 importedSites: [{ siteId: 'site-92', url: 'https://news.acme.com' }] as ImportedSiteType[],
7 billingInfo: { planId: 'business_monthly', contactEmail: 'billing@acme.com' } as BillingInfo
8};
9const result: CreateTenant200Response = await createTenant(tenantId, createTenantBody);
10

删除租户 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
surestring

响应

返回: FlagCommentPublic200Response

示例

deleteTenant 示例
Copy Copy
1
2const tenantId: string = 'tenant_742b9c';
3const flagId: string = 'flag_1a2b3c';
4const resultWithoutSure: FlagCommentPublic200Response = await deleteTenant(tenantId, flagId);
5const sureConfirmation: string = 'confirmed';
6const resultWithSure: FlagCommentPublic200Response = await deleteTenant(tenantId, flagId, sureConfirmation);
7

获取租户 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring

响应

返回:GetTenant200Response

示例

getTenant 示例
Copy Copy
1
2const tenantId: string = 'fc_tenant_6b3e2a';
3const id: string = 'site_42f1';
4const tenantResponse: GetTenant200Response = await getTenant(tenantId, id);
5const tenant: APITenant | undefined = tenantResponse.tenant;
6const primaryDomain: APIDomainConfiguration | undefined = tenant?.domainConfiguration?.[0];
7

获取租户列表 Internal Link

参数

NameTypeRequiredDescription
tenantIdstringYes
metastringNo
skipnumberNo

响应

返回: GetTenants200Response

示例

getTenants 示例
Copy Copy
1
2const tenantId: string = "fcom-tenant-8b4f2a1c";
3const meta: string = "include=domains,billing&status=active";
4const skip: number = 20;
5const response: GetTenants200Response = await getTenants(tenantId, meta, skip);
6console.log(response);
7

更新租户 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updateTenantBodyUpdateTenantBody

响应

返回: FlagCommentPublic200Response

示例

updateTenant 示例
Copy Copy
1
2const tenantId: string = 'tenant_84f12';
3const id: string = 'flag_192b';
4const updateTenantBody: UpdateTenantBody = {
5 name: 'Acme Media',
6 billingInfo: { plan: 'enterprise', seats: 25, nextBillingDate: '2026-07-01' },
7 apiDomainConfiguration: { primaryDomain: 'comments.acme.com', additionalDomains: ['acme.com'] },
8 importedSites: [{ siteUrl: 'https://blog.acme.com', archived: false }], // 可选
9 commentSettings: { htmlRenderingMode: 'sanitized', deletionMode: 'soft' } // 可选
10} as UpdateTenantBody;
11const result: FlagCommentPublic200Response = await updateTenant(tenantId, id, updateTenantBody);
12

更改工单状态 Internal Link

参数

名称类型必需描述
tenantIdstring
userIdstring
idstring
changeTicketStateBodyChangeTicketStateBody

响应

返回: ChangeTicketState200Response

示例

changeTicketState 示例
Copy Copy
1
2const tenantId: string = 'tenant_8a7d3f4b';
3const userId: string = 'user_5d1a9b2c';
4const id: string = 'ticket_1024';
5const changeTicketStateBody: ChangeTicketStateBody = {
6 state: 'closed',
7 notifyParticipants: true, // 演示可选参数
8 comment: 'Resolved by support — follow-up not required.'
9};
10const result: ChangeTicketState200Response = await changeTicketState(tenantId, userId, id, changeTicketStateBody);
11

创建工单 Internal Link

参数

名称类型必填描述
tenantIdstring
userIdstring
createTicketBodyCreateTicketBody

响应

返回: CreateTicket200Response

示例

createTicket 示例
Copy Copy
1
2const tenantId: string = 'tenant_acme_corp';
3const userId: string = 'moderator_jane';
4const createTicketBody: CreateTicketBody = {
5 subject: 'Mass spam reports on article 789',
6 description: 'Multiple identical spam comments posted under article 789. Needs moderation and bulk removal.',
7 priority: 'high',
8 contactEmail: 'jane@acme-corp.com',
9 metadata: { articleId: '789', reportedCount: 12 } // 可选元数据示例
10};
11const ticket: CreateTicket200Response = await createTicket(tenantId, userId, createTicketBody);
12

获取工单 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
userIdstring

响应

返回:GetTicket200Response

示例

getTicket 示例
Copy Copy
1
2const tenantId: string = 'acme-corp';
3const ticketId: string = 'TCKT-20250615-42';
4const userId: string = 'user_84b2';
5
6const ticketWithUser: GetTicket200Response = await getTicket(tenantId, ticketId, userId);
7const ticketWithoutUser: GetTicket200Response = await getTicket(tenantId, ticketId);
8
9console.log(ticketWithUser.id, ticketWithoutUser.id);
10

获取工单列表 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
userIdstring
statenumber
skipnumber
limitnumber

响应

返回: GetTickets200Response

示例

getTickets 示例
Copy Copy
1
2const tenantId: string = 'tenant_acme_01';
3const userId: string = 'user_87b3';
4const state: number = 2;
5const skip: number = 0;
6const limit: number = 50;
7
8const tickets: GetTickets200Response = await getTickets(tenantId, userId, state, skip, limit);
9

获取翻译 Internal Link

参数

名称类型必填描述
namespacestring
componentstring
localestring
useFullTranslationIdsboolean

响应

返回: GetTranslations200Response

示例

getTranslations 示例
Copy Copy
1
2const namespaceName: string = 'site-ui';
3const componentName: string = 'comment-widget';
4const locale: string = 'fr-FR';
5const useFullTranslationIds: boolean = true;
6const translationsWithLocale: GetTranslations200Response = await getTranslations(namespaceName, componentName, locale, useFullTranslationIds);
7const translationsDefault: GetTranslations200Response = await getTranslations(namespaceName, componentName);
8

上传图片 Internal Link

上传并调整图像大小

参数

名称类型必需描述
tenantIdstring
fileBlob
sizePresetSizePreset
urlIdstring

响应

返回: UploadImageResponse


通过 ID 获取用户徽章进度 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: GetUserBadgeProgressById200Response

示例

getUserBadgeProgressById 示例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-241';
3const badgeId: string = 'user-78b3d-badge-3';
4const response: GetUserBadgeProgressById200Response = await getUserBadgeProgressById(tenantId, badgeId);
5const progress: UserBadgeProgress | undefined = (response as unknown as { progress?: UserBadgeProgress }).progress;
6const percentComplete: number | undefined = progress?.percentage;
7console.log('Badge progress percent complete:', percentComplete);
8

通过用户 ID 获取用户徽章进度 Internal Link

参数

名称类型必填描述
tenantIdstring
userIdstring

响应

返回:GetUserBadgeProgressById200Response

示例

getUserBadgeProgressByUserId 示例
Copy Copy
1
2const tenantId: string = 'acme-inc-tenant-01';
3const userId: string = 'user_73c9b2';
4const progress: GetUserBadgeProgressById200Response = await getUserBadgeProgressByUserId(tenantId, userId);
5
6async function maybeFetchProgress(tenant: string, user?: string): Promise<GetUserBadgeProgressById200Response | null> {
7 if (!user) return null;
8 return await getUserBadgeProgressByUserId(tenant, user);
9}
10
11const optionalResult: GetUserBadgeProgressById200Response | null = await maybeFetchProgress(tenantId, userId);
12

获取用户徽章进度列表 Internal Link

参数

名称类型必需说明
tenantIdstring
userIdstring
limitnumber
skipnumber

响应

返回: GetUserBadgeProgressList200Response

示例

getUserBadgeProgressList 示例
Copy Copy
1
2const tenantId: string = 'tenant_4f3a2b9c';
3const userId: string = 'user_7721d';
4const limit: number = 20;
5const skip: number = 0;
6const result: GetUserBadgeProgressList200Response = await getUserBadgeProgressList(tenantId, userId, limit, skip);
7

创建用户徽章 Internal Link

参数

名称类型必填描述
tenantIdstring
createUserBadgeParamsCreateUserBadgeParams

响应

返回:CreateUserBadge200Response

示例

createUserBadge 示例
Copy Copy
1
2const tenantId: string = "tenant_7f4b2a";
3const createUserBadgeParams: CreateUserBadgeParams = {
4 code: "top_contributor",
5 title: "Top Contributor",
6 description: "Awarded for 100 high-quality comments",
7 iconUrl: "https://cdn.fastcomments.com/badges/top_contributor.svg",
8 isActive: true,
9 criteria: { commentsRequired: 100 },
10 customConfig: { displayOnProfile: true } // 示例:可选参数
11};
12const result: CreateUserBadge200Response = await createUserBadge(tenantId, createUserBadgeParams);
13

删除用户徽章 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring

响应

返回: UpdateUserBadge200Response

示例

deleteUserBadge 示例
Copy Copy
1
2const tenantId: string = "tenant_8b3f2c7a";
3const badgeIdOptional: string | undefined = Math.random() > 0.5 ? "badge_4f9a21" : undefined;
4const id: string = badgeIdOptional ?? "badge_backup_01";
5const result: UpdateUserBadge200Response = await deleteUserBadge(tenantId, id);
6

获取用户徽章 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: GetUserBadge200Response

示例

getUserBadge 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_6b8f2a1c';
4 const id: string = 'badge_9f3d4b2a';
5 const response: GetUserBadge200Response = await getUserBadge(tenantId, id);
6 const badge: UserBadge | undefined = response.userBadge;
7 const badgeName: string | undefined = badge?.name;
8 console.log('Retrieved badge name:', badgeName);
9})();
10

获取用户徽章列表 Internal Link

参数

名称类型必需描述
tenantIdstring
userIdstring
badgeIdstring
typenumber
displayedOnCommentsboolean
limitnumber
skipnumber

响应

返回: GetUserBadges200Response

示例

getUserBadges 示例
Copy Copy
1
2const tenantId: string = 'tenant_7f9a12';
3const userId: string = 'user_42b7';
4const badgeId: string = 'badge_top_contributor';
5const type: number = 2;
6const displayedOnComments: boolean = true;
7const limit: number = 25;
8const skip: number = 0;
9const badges: GetUserBadges200Response = await getUserBadges(tenantId, userId, badgeId, type, displayedOnComments, limit, skip);
10

更新用户徽章 Internal Link

参数

名称类型必需描述
tenantIdstring
idstring
updateUserBadgeParamsUpdateUserBadgeParams

响应

返回: UpdateUserBadge200Response

示例

updateUserBadge 示例
Copy Copy
1
2const tenantId: string = "tenant_9a8b7c";
3const id: string = "badge_a1b2c3";
4const updateUserBadgeParams: UpdateUserBadgeParams = {
5 title: "Community Helper",
6 description: "Awarded for providing 50 helpful answers",
7 iconUrl: "https://cdn.fastcomments.com/badges/community-helper.png",
8 isActive: true,
9 expiryDate: undefined
10};
11const result: UpdateUserBadge200Response = await updateUserBadge(tenantId, id, updateUserBadgeParams);
12

获取用户通知计数 Internal Link

参数

名称类型必需描述
tenantIdstring
ssostring

响应

返回:GetUserNotificationCount200Response

示例

getUserNotificationCount 示例
Copy Copy
1
2const tenantId: string = 'tenant_acme_01';
3const ssoToken: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso_payload.signature';
4const notificationCountNoSSO: GetUserNotificationCount200Response = await getUserNotificationCount(tenantId);
5const notificationCountWithSSO: GetUserNotificationCount200Response = await getUserNotificationCount(tenantId, ssoToken);
6

获取用户通知 Internal Link


参数

名称类型必填描述
tenantIdstring
urlIdstring
pageSizenumber
afterIdstring
includeContextboolean
afterCreatedAtnumber
unreadOnlyboolean
dmOnlyboolean
noDmboolean
includeTranslationsboolean
includeTenantNotificationsboolean
ssostring

响应

返回: GetUserNotifications200Response

示例

getUserNotifications 示例
Copy Copy
1
2const tenantId: string = "tenant_8271";
3const urlId: string = "https://www.news-site.com/articles/2026/06/15/ai-updates";
4const pageSize: number = 25;
5const afterId: string = "notif_abc123";
6const includeContext: boolean = true;
7const afterCreatedAt: number = Date.now() - 86_400_000;
8const unreadOnly: boolean = true;
9const dmOnly: boolean = false;
10const noDm: boolean = false;
11const includeTranslations: boolean = true;
12const includeTenantNotifications: boolean = true;
13const sso: string = "sso_token_xyz_987";
14
15const notifications: GetUserNotifications200Response = await getUserNotifications(
16 tenantId,
17 urlId,
18 pageSize,
19 afterId,
20 includeContext,
21 afterCreatedAt,
22 unreadOnly,
23 dmOnly,
24 noDm,
25 includeTranslations,
26 includeTenantNotifications,
27 sso
28);
29

重置用户通知计数 Internal Link

参数

名称类型必填描述
tenantIdstring
ssostring

响应

返回: ResetUserNotifications200Response

示例

resetUserNotificationCount 示例
Copy Copy
1
2const tenantId: string = "tenant_8a3f2b6c";
3const ssoToken: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyX2QxMjM0IiwiaWF0IjoxNjI1MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
4const resetResponseWithSso: ResetUserNotifications200Response = await resetUserNotificationCount(tenantId, ssoToken);
5const resetResponseWithoutSso: ResetUserNotifications200Response = await resetUserNotificationCount(tenantId);
6

重置用户通知 Internal Link

参数

名称类型必填描述
tenantIdstring
afterIdstring
afterCreatedAtnumber
unreadOnlyboolean
dmOnlyboolean
noDmboolean
ssostring

响应

返回: ResetUserNotifications200Response

示例

resetUserNotifications 示例
Copy Copy
1
2const tenantId: string = "tenant_9b1f2";
3const afterId: string = "notification_0001";
4const afterCreatedAt: number = Date.now() - 60 * 60 * 1000; // 一小时前
5const unreadOnly: boolean = true;
6const dmOnly: boolean = false;
7const noDm: boolean = false;
8const sso: string = "sso_session_7f2d";
9const result: ResetUserNotifications200Response = await resetUserNotifications(
10 tenantId,
11 afterId,
12 afterCreatedAt,
13 unreadOnly,
14 dmOnly,
15 noDm,
16 sso
17);
18

更新用户评论订阅状态 Internal Link


启用或禁用特定评论的通知。

参数

NameTypeRequiredDescription
tenantIdstring
notificationIdstring
optedInOrOutUpdateUserNotificationCommentSubscriptionStatusOptedInOrOutEnum
commentIdstring
ssostring

响应

返回: UpdateUserNotificationStatus200Response

示例

updateUserNotificationCommentSubscriptionStatus 示例
Copy Copy
1
2const tenantId: string = 'f3a9c8b0-4d2e-4f8a-9c3b-1234567890ab';
3const notificationId: string = '62a1f4d2-8c7b-4e1a-aaa1-abcdef123456';
4const commentId: string = '7e4a2b1c-1234-5678-90ab-cdef12345678';
5const optedInOrOut: UpdateUserNotificationCommentSubscriptionStatusOptedInOrOutEnum = UpdateUserNotificationCommentSubscriptionStatusOptedInOrOutEnum.OptedIn;
6const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ssoPayload.signature';
7const response: UpdateUserNotificationStatus200Response = await updateUserNotificationCommentSubscriptionStatus(tenantId, notificationId, optedInOrOut, commentId, sso);
8

更新用户页面订阅状态 Internal Link

启用或禁用某个页面的通知。当用户订阅某个页面时,会为新的根评论创建通知,并且也会

参数

名称类型必需描述
tenantIdstringYes
urlIdstringYes
urlstringYes
pageTitlestringYes
subscribedOrUnsubscribedUpdateUserNotificationPageSubscriptionStatusSubscribedOrUnsubscribedEnumYes
ssostringNo

响应

返回: UpdateUserNotificationStatus200Response

示例

updateUserNotificationPageSubscriptionStatus 示例
Copy Copy
1
2const tenantId: string = 'tenant_7f3b2';
3const urlId: string = 'article_987';
4const url: string = 'https://www.news-site.com/articles/2026/pasta-guide';
5const pageTitle: string = 'The Definitive Guide to Cooking Pasta';
6const subscribedOrUnsubscribed: UpdateUserNotificationPageSubscriptionStatusSubscribedOrUnsubscribedEnum = UpdateUserNotificationPageSubscriptionStatusSubscribedOrUnsubscribedEnum.Subscribed;
7const sso: string = 'sso-token-62b9f1';
8const result: UpdateUserNotificationStatus200Response = await updateUserNotificationPageSubscriptionStatus(tenantId, urlId, url, pageTitle, subscribedOrUnsubscribed, sso);
9

更新用户通知状态 Internal Link

参数

名称类型必需描述
tenantIdstring
notificationIdstring
newStatusUpdateUserNotificationStatusNewStatusEnum
ssostring

响应

返回: UpdateUserNotificationStatus200Response

示例

updateUserNotificationStatus 示例
Copy Copy
1
2const tenantId: string = 'tenant_5f2a8b9c';
3const notificationId: string = 'notif_987654321';
4const newStatus: UpdateUserNotificationStatusNewStatusEnum = UpdateUserNotificationStatusNewStatusEnum.Read;
5const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.payload.signature';
6const result: UpdateUserNotificationStatus200Response = await updateUserNotificationStatus(tenantId, notificationId, newStatus, sso);
7

获取用户在线状态 Internal Link

参数

名称类型必填描述
tenantIdstring
urlIdWSstring
userIdsstring

响应

返回:GetUserPresenceStatuses200Response

示例

getUserPresenceStatuses 示例
Copy Copy
1
2const tenantId: string = 'tenant_42';
3const urlIdWS: string = 'wss://comments.fastsite.com/ws/tenant_42';
4const userIds: string = 'user_9012,user_3478';
5const includePresenceMetadata: boolean | undefined = true; // 可选参数示例
6const presenceStatuses: GetUserPresenceStatuses200Response = await getUserPresenceStatuses(tenantId, urlIdWS, userIds);
7

搜索用户 Internal Link

参数

名称类型必需描述
tenantIdstring
urlIdstring
usernameStartsWithstring
mentionGroupIdsArray
ssostring
searchSectionSearchUsersSearchSectionEnum

响应

返回: SearchUsers200Response

示例

searchUsers 示例
Copy Copy
1
2const tenantId: string = 'tenant_7890';
3const urlId: string = 'news/2026-06-15-world-cup-final';
4const usernameStartsWith: string = 'mar';
5const mentionGroupIds: string[] = ['staff', 'trusted-commenters'];
6const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI0NTY3OCJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
7const searchSection: SearchUsersSearchSectionEnum = SearchUsersSearchSectionEnum.Commenters;
8const response: SearchUsers200Response = await searchUsers(tenantId, urlId, usernameStartsWith, mentionGroupIds, sso, searchSection);
9

获取用户 Internal Link

参数

名称类型必填描述
tenantIdstring
idstring

响应

返回: GetUser200Response

示例

getUser 示例
Copy Copy
1
2const tenantId: string = 'fastcomments_corp';
3const id: string = 'user_9f8b7c6d-5e4a-3b2c-1f0e-123456789abc';
4const response: GetUser200Response = await getUser(tenantId, id);
5const userEmail: string | undefined = response.user?.email;
6const displayName: string | undefined = response.user?.displayName
7

创建投票 Internal Link

参数

名称类型必需描述
tenantIdstring
commentIdstring
directionCreateVoteDirectionEnum
userIdstring
anonUserIdstring

响应

返回: VoteComment200Response

示例

createVote 示例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-001';
3const commentId: string = 'cmt_8f3b2a9d';
4const direction: CreateVoteDirectionEnum = CreateVoteDirectionEnum.Up;
5const userId: string = 'user_5021';
6const anonUserId: string = 'anon_7a9c';
7
8const voteResponse: VoteComment200Response = await createVote(tenantId, commentId, direction, userId, anonUserId);
9

删除投票 Internal Link

参数

NameTypeRequiredDescription
tenantIdstring
idstring
editKeystring

响应

返回: DeleteCommentVote200Response

示例

deleteVote 示例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_8421';
4 const id: string = 'vote_3f9b7c2a';
5 const editKey: string = 'edit_7Xk9LpQ';
6 const responseWithoutEdit: DeleteCommentVote200Response = await deleteVote(tenantId, id);
7 const responseWithEdit: DeleteCommentVote200Response = await deleteVote(tenantId, id, editKey);
8 console.log(responseWithoutEdit, responseWithEdit);
9})();
10

获取投票 Internal Link


参数

名称类型必需描述
tenantIdstring
urlIdstring

响应

返回:GetVotes200Response

示例

getVotes 示例
Copy Copy
1
2const tenantId: string = 'tenant_7f8e91c2';
3const urlId: string = 'https://www.sportsdaily.com/news/2026/06/15/championship-game-recap';
4const votes: GetVotes200Response = await getVotes(tenantId, urlId);
5console.log(votes);
6

获取用户的投票 Internal Link

参数

名称类型必需描述
tenantIdstring
urlIdstring
userIdstring
anonUserIdstring

响应

返回: GetVotesForUser200Response

示例

getVotesForUser 示例
Copy Copy
1
2const tenantId: string = 'tenant_9b8f7c6d';
3const urlId: string = 'articles/product-update-2026';
4const userId: string = 'user_c12345';
5const anonUserId: string = 'anon_7f4e2a';
6const votes: GetVotesForUser200Response = await getVotesForUser(tenantId, urlId, userId, anonUserId);
7

需要帮助?

如果您在使用 JavaScript/TypeScript SDK 时遇到任何问题或有疑问,请:

贡献

欢迎贡献!请访问 GitHub 仓库 获取贡献指南。