跳到文档正文

资料、关注与关联账号事件

账号事件包含观察到的资料、关注和关联账号关系变更。

运行五分钟快速开始
在聊天中打开
按产品代码校对:2026年9月2日

账号事件类型

op 分流。遇到未知账号操作时忽略消息,不要关闭 WebSocket。

账号事件契约

typescript
type VerifiedType = 'blue' | 'business' | 'government' | 'verified' | 'none';
type TweetVerifiedLabel = {
  badge: string | null;
  description: string;
  url: string | null;
};
 
type TweetAuthor = {
  banner?: string;
  bio?: string;
  followersCount?: number;
  followingCount?: number;
  id?: string;
  joinedAt?: number;
  location?: string;
  metrics?: {
    likes?: number;
    tweets?: number;
  };
  // Includes a leading @ when present, for example "@elonmusk".
  handle?: string;
  name?: string;
  platform?: 'twitter' | 'truth_social' | 'binance_square';
  profileImage?: string;
  url?: string;
  verifiedLabel?: TweetVerifiedLabel;
  verifiedType?: VerifiedType;
};
 
type AccountEventActor = TweetAuthor & {
  websiteUrl?: string;
};
 
type ProfileUpdateEvent = {
  kind: 'PROFILE';
  eventId: string;
  observedAt: number;
  receivedAt?: number;
  actor: AccountEventActor;
  changes: {
    avatar?: string;
    banner?: string;
    bio?: string;
    handle?: string;
    location?: string;
    name?: string;
    verifiedLabel?: TweetVerifiedLabel | null;
    websiteUrl?: string | null;
  };
  previous?: {
    avatar?: string;
    banner?: string;
    bio?: string;
    handle?: string;
    location?: string;
    name?: string;
    verifiedLabel?: TweetVerifiedLabel | null;
    websiteUrl?: string | null;
  };
};
 
type FollowEvent = {
  kind: 'FOLLOW';
  eventId: string;
  observedAt: number;
  receivedAt?: number;
  actor: AccountEventActor;
  target: AccountEventActor & {
    handle: string;
  };
};
 
type UnfollowEvent = {
  kind: 'UNFOLLOW';
  eventId: string;
  observedAt: number;
  receivedAt?: number;
  actor: AccountEventActor;
  target: AccountEventActor & {
    handle: string;
  };
};
 
type AffiliateAccountIdentity = AccountEventActor & {
  id: string;
};
 
type AffiliateUpdateEvent = {
  action: 'added' | 'removed';
  eventId: string;
  observedAt: number;
  receivedAt?: number;
  organization: AffiliateAccountIdentity;
  member: AffiliateAccountIdentity;
};

account/profile_update

只应用 changes 中存在的字段。字段缺失表示没有变化。

资料更新事件

json
{
  "v": 1,
  "t": "account",
  "op": "profile_update",
  "id": "profile-1",
  "ts": 1772000001060,
  "d": {
    "actor": {
      "id": "10228272",
      "handle": "@TeamYouTube",
      "name": "TeamYouTube",
      "profileImage": "https://pbs.twimg.com/media/avatar.jpg",
      "websiteUrl": "https://youtube.com"
    },
    "changes": {
      "handle": "@TeamYouTube",
      "name": "Team YouTube",
      "websiteUrl": "https://youtube.com/new"
    },
    "eventId": "profile-1",
    "kind": "PROFILE",
    "observedAt": 1772000001060,
    "previous": {
      "handle": "@OldTeam"
    },
    "receivedAt": 1772000001050
  }
}

account/follow

使用稳定的发起账号和目标账号标识符存储观察到的关系。

关注事件

json
{
  "v": 1,
  "t": "account",
  "op": "follow",
  "id": "follow-1",
  "ts": 1772000001060,
  "d": {
    "actor": {
      "id": "10228272",
      "handle": "@TeamYouTube"
    },
    "eventId": "follow-1",
    "kind": "FOLLOW",
    "observedAt": 1772000001060,
    "target": {
      "id": "4398626122",
      "handle": "@OpenAI"
    },
    "receivedAt": 1772000001050
  }
}

account/unfollow

使用相同标识符移除观察到的关系。

取消关注事件

json
{
  "v": 1,
  "t": "account",
  "op": "unfollow",
  "id": "unfollow-1",
  "ts": 1772000001060,
  "d": {
    "actor": {
      "id": "10228272",
      "handle": "@TeamYouTube"
    },
    "eventId": "unfollow-1",
    "kind": "UNFOLLOW",
    "observedAt": 1772000001060,
    "target": {
      "id": "4398626122",
      "handle": "@OpenAI"
    },
    "receivedAt": 1772000001050
  }
}

account/affiliate_update

(organization.id, member.id) 作为关系键,幂等地应用 addedremoved 操作。eventId 仅用于识别完全相同的重放。

关键词过滤不适用。使用 GET /api/history?type=affiliate 回放已存变更。History 不是当前列表快照,也不会回补启用此功能前的变更。

关联账号更新事件

json
{
  "v": 1,
  "t": "account",
  "op": "affiliate_update",
  "id": "affiliate-update-1",
  "ts": 1772000001060,
  "d": {
    "action": "added",
    "organization": {
      "id": "10228272",
      "handle": "@TeamYouTube",
      "name": "TeamYouTube",
      "profileImage": "https://pbs.twimg.com/media/avatar.jpg",
      "websiteUrl": "https://youtube.com"
    },
    "member": {
      "id": "4398626122",
      "handle": "@OpenAI",
      "name": "OpenAI",
      "profileImage": "https://pbs.twimg.com/media/member-avatar.jpg"
    },
    "eventId": "affiliate-update-1",
    "observedAt": 1772000001060,
    "receivedAt": 1772000001050
  }
}