跳转到主要内容

对象模型

Tweet

Tweet 是构建所有 X 内容的基本单元。Tweet 对象包含一系列“根级”字段,例如 idtextcreated_at。Tweet 对象还是多个子对象的“父”对象,包括 usermediapollplace。在请求 Tweet 对象的这些根级字段时,请使用字段参数 tweet.fields 可以在 user 资源中查找并展开 Tweet 对象。与所请求 Tweet 相关的其他 Tweet 也可以在 Tweet 资源中查找并展开。该对象可通过在 user 资源中使用 ?expansions=pinned_tweet_id 或在 Tweet 资源中使用 ?expansions=referenced_tweets.id 来展开,以仅获取默认字段的对象。在请求其他字段以补全对象时,请将该 expansion 与字段参数 tweet.fields 搭配使用。
字段值类型描述使用方式
id(默认)字符串所请求的 Tweet 的唯一标识符。使用此方法以编程方式获取特定的 Tweet。
文本(默认)字符串Tweet 的实际 UTF-8 文本。参见twitter-text查看有效字符的详细说明。关键词抽取与情感分析/分类。
edit_history_tweet_ids(默认)对象用于标示某条 Tweet 所有版本的唯一标识符。未经过编辑的 Tweet 只有一个 id;有编辑历史的 Tweet 会有多个 id。使用这些信息查找某条 Tweet 的编辑记录。
文章对象包含此 Tweet 中所含 Article 的元数据。用于获取文章的文本和实体。
附件对象指定此 Tweet(如有)所包含的附件类型。了解针对所请求 expansions 返回的对象。
author_id字符串发布此 Tweet 的用户的唯一标识符。填充(hydrate)User 对象,分享数据集以供同行评审。
card_uri字符串此条 Tweet 中所含 Card 的 URI。
community_id字符串此 Post 所属 Community 的唯一标识符。
context_annotations数组包含该 Tweet 的上下文注释。实体识别/抽取、主题分析。
conversation_id字符串该会话中原始 Tweet 的 Tweet ID(包括直接回复及其后续层级的回复)。用它从一条 Tweet 重建完整的会话。
created_at日期(ISO 8601)Tweet 的创建时间。适用于时间序列分析,并帮助了解 Tweet 的创建时间。
display_text_range数组一个数组,包含要展示的文本片段的起始索引和结束索引。有助于了解长篇 Post 默认显示的文本区段。
编辑_控件对象指示 Tweet 还可编辑的剩余时间和剩余编辑次数。用于判断某条 Tweet 是否具备可编辑资格。
entities(实体)对象从 Tweet 文本中解析出的实体。请参阅 Twitter 对象中的 entities。提供有关话题标签、URL、提及等的附加信息。
地理对象指示带地理标签的 Tweet 的位置或地点。使用此项来获取带地理标记的 Tweet 的位置。
in_reply_to_user_id字符串如果所表示的 Tweet 为回复,则此字段将包含原始 Tweet 的作者 id。确定某条 Tweet 是否为对另一条 Tweet 的回复。
语言字符串如果由 Twitter 检测到,则为该 Tweet 的语言。按口语语言对 Tweet 进行分类。
非公开_指标对象请求时该 Tweet 的非公开参与度指标。需要用户上下文认证。确定该 Tweet 产生的总展示次数。
note_tweet对象包含长文 Post 的完整文本(>280 个字符)。获取一条 Post 的完整文本。
organic_metrics对象在请求时点、在自然曝光情境下为该 Tweet 追踪的互动指标。需要用户上下文认证。衡量该 Tweet 的自然参与度。
可能_敏感布尔指示该内容是否可能被识别为敏感信息。研究特定类型内容的传播情况。
promoted_metrics对象在推广场景中追踪的该 Tweet 的互动指标,数值以请求时的状态为准。需要用户上下文认证。在 Tweet 推广期间衡量其互动表现。
public_metrics对象请求时该 Tweet 的公开互动指标。衡量 Tweet 参与度。
referenced_tweets数组此 Tweet 所关联的 Tweet 列表,例如转推、引用 Tweet 或回复。理解转推等内容的对话属性。
reply_settings字符串显示哪些人可以回复指定的 Tweet。选项包括”所有人”,“提及_用户”,和”粉丝”。确定该 Tweet 的对话回复设置。
已扣留对象包含与被屏蔽内容相关的屏蔽详情因法律要求隐藏的内容
作用域(scopes)对象包含该 Tweet 的范围详情。指明可查看该 Post 的对象。仅对推广的 Post 返回。
media_metadata数组包含该 Tweet 的媒体附件元数据。获取更多元数据,例如alt_text某条 Tweet 的’的媒体附件。
检索 Tweet 对象 示例请求 在以下请求中,我们通过 Tweets lookup 端点为该 Tweet 指定返回的 fields。请务必将 $BEARER_TOKEN 替换为你自己生成的 Bearer Token
curl --request GET 'https://api.x.com/2/tweets?ids=1212092628029698048&tweet.fields=attachments,author_id,context_annotations,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,public_metrics,referenced_tweets,text,withheld&expansions=referenced_tweets.id' --header 'Authorization: Bearer $BEARER_TOKEN'
示例回复
{
  "data": [
    {
      "text": "我们相信,最好的 API 未来版本将源于与你们共同构建。向所有在 Twitter 平台上构建的开发者致意,愿新的一年依旧精彩。我们迫不及待想在新的一年里继续与大家合作。https://t.co/yvxdK6aOo2",
      "edit_history_tweet_ids": [
        "1212092628029698048"
      ],
      "lang": "en",
      "in_reply_to_user_id": "2244994945",
      "entities": {
        "urls": [
          {
            "start": 222,
            "end": 245,
            "url": "https://t.co/yvxdK6aOo2",
            "expanded_url": "https://x.com/LovesNandos/status/1211797914437259264/photo/1",
            "display_url": "pic.x.com/yvxdK6aOo2",
            "media_key": "16_1211797899316740096"
          }
        ],
        "annotations": [
          {
            "start": 42,
            "end": 44,
            "probability": 0.5359,
            "type": "Other",
            "normalized_text": "API"
          },
          {
            "start": 144,
            "end": 150,
            "probability": 0.9832,
            "type": "Other",
            "normalized_text": "Twitter"
          }
        ]
      },
      "author_id": "2244994945",
      "referenced_tweets": [
        {
          "type": "replied_to",
          "id": "1212092627178287104"
        }
      ],
      "id": "1212092628029698048",
      "public_metrics": {
        "retweet_count": 7,
        "reply_count": 3,
        "like_count": 38,
        "quote_count": 1
      },
      "context_annotations": [
        {
          "domain": {
            "id": "29",
            "name": "事件 [实体服务]",
            "description": "现实世界中的事件。"
          },
          "entity": {
            "id": "1186637514896920576",
            "name": "除夕夜"
          }
        },
        {
          "domain": {
            "id": "29",
            "name": "事件 [实体服务]",
            "description": "现实世界中的事件。"
          },
          "entity": {
            "id": "1206982436287963136",
            "name": "新年快乐:全球各地终于都迎来 2020 年!",
            "description": "当全球各地的人们迎接新年时,欣赏烟花与其他庆祝活动。\n照片来源:@GettyImages "
          }
        },
        {
          "domain": {
            "id": "119",
            "name": "节日",
            "description": "诸如圣诞节或万圣节等节日"
          },
          "entity": {
            "id": "1186637514896920576",
            "name": "除夕夜"
          }
        },
        {
          "domain": {
            "id": "119",
            "name": "节日",
            "description": "诸如圣诞节或万圣节等节日"
          },
          "entity": {
            "id": "1206982436287963136",
            "name": "新年快乐:全球各地终于都迎来 2020 年!",
            "description": "当全球各地的人们迎接新年时,欣赏烟花与其他庆祝活动。\n照片来源:@GettyImages "
          }
        },
        {
          "domain": {
            "id": "30",
            "name": "实体 [实体服务]",
            "description": "实体服务的顶级域,实体服务中的每个条目都应归于此域"
          },
          "entity": {
            "id": "781974596752842752",
            "name": "服务"
          }
        },
        {
          "domain": {
            "id": "47",
            "name": "品牌",
            "description": "品牌与公司"
          },
          "entity": {
            "id": "10045225402",
            "name": "Twitter"
          }
        },
        {
          "domain": {
            "id": "131",
            "name": "统一的 Twitter 分类法",
            "description": "用户兴趣的分类法。"
          },
          "entity": {
            "id": "10045225402",
            "name": "Twitter"
          }
        },
        {
          "domain": {
            "id": "131",
            "name": "统一的 Twitter 分类法",
            "description": "用户兴趣的分类法。"
          },
          "entity": {
            "id": "847868745150119936",
            "name": "家庭与人际关系",
            "description": "爱好与兴趣"
          }
        },
        {
          "domain": {
            "id": "131",
            "name": "统一的 Twitter 分类法",
            "description": "用户兴趣的分类法。"
          },
          "entity": {
            "id": "1196446161223028736",
            "name": "社交媒体"
          }
        },
        {
          "domain": {
            "id": "29",
            "name": "事件 [实体服务]",
            "description": "现实世界中的事件。"
          },
          "entity": {
            "id": "1206982436287963136",
            "name": "新年快乐:全球各地终于都迎来 2020 年!",
            "description": "当全球各地的人们迎接新年时,欣赏烟花与其他庆祝活动。\n照片来源:@GettyImages "
          }
        },
        {
          "domain": {
            "id": "119",
            "name": "节日",
            "description": "诸如圣诞节或万圣节等节日"
          },
          "entity": {
            "id": "1206982436287963136",
            "name": "新年快乐:全球各地终于都迎来 2020 年!",
            "description": "当全球各地的人们迎接新年时,欣赏烟花与其他庆祝活动。\n照片来源:@GettyImages "
          }
        }
      ],
      "created_at": "2019-12-31T19:26:16.000Z",
      "attachments": {
        "media_keys": [
          "16_1211797899316740096"
        ]
      },
      "possibly_sensitive": false
    }
  ],
  "includes": {
    "tweets": [
      {
        "text": "没有你们一路上的反馈,这些发布就无法实现,感谢每一位贡献时间和想法的你。还有更多反馈吗?告诉我们吧 ⬇️ https://t.co/Vxp4UKnuJ9",
        "edit_history_tweet_ids": [
          "1212092627178287104"
        ],
        "lang": "en",
        "in_reply_to_user_id": "2244994945",
        "entities": {
          "urls": [
            {
              "start": 187,
              "end": 210,
              "url": "https://t.co/Vxp4UKnuJ9",
              "expanded_url": "https://twitterdevfeedback.uservoice.com/forums/921790-twitter-developer-labs",
              "display_url": "twitterdevfeedback.uservoice.com/forums/921790-…",
              "status": 200,
              "title": "我们的反馈渠道更新",
              "description": "我们以开放方式构建开发者平台,离不开你的意见与反馈。过去一年里,直接倾听你和你的应用用户的声音,帮助我们打造更契合你所帮助识别的用例的开发者产品。我们希望把这种方式作为构建产品的常态。展望未来,我们正在整合反馈渠道。随时随地与你对接。从今天起,我们将停用 UserVoice 反馈渠道,转而通过更为频繁的直接交流与您联络……",
              "unwound_url": "https://devcommunity.x.com/t/updates-on-our-feedback-channels/169706"
            }
          ]
        },
        "author_id": "2244994945",
        "referenced_tweets": [
          {
            "type": "replied_to",
            "id": "1212092626247110657"
          }
        ],
        "id": "1212092627178287104",
        "public_metrics": {
          "retweet_count": 2,
          "reply_count": 1,
          "like_count": 19,
          "quote_count": 0
        },
        "created_at": "2019-12-31T19:26:16.000Z",
        "possibly_sensitive": false
      }
    ]
  }

User

user 对象包含用于描述所引用用户的 Twitter 账号元数据。user 对象是 users lookup 端点返回的主要对象。在该端点请求附加用户字段时,只需使用字段参数 user.fields user 对象也可能作为子对象出现在 Tweet 对象中,并可被展开。可通过 ?expansions=author_id?expansions=in_reply_to_user_id 进行展开,以获取仅包含默认字段的精简对象。若需请求更多字段以补全该对象,请将该扩展与字段参数配合使用:user.fields。  
字段取值类型描述使用方式
id(默认)字符串该用户的唯一标识符。

"id": "2244994945"
使用此方法以编程方式获取特定 Twitter 用户的信息。
名称(默认)字符串用户在其个人资料中设置的名称。不一定是本人的真实姓名。通常限制为 50 个字符,但可能会调整。

"name": "Twitter Dev"
用户名(默认)字符串该用户用于自我标识的 Twitter 屏幕名称、用户名(handle)或别名。用户名具有唯一性,但可能会变更。通常最长为 15 个字符,但某些早期账户可能使用更长的名称。

"username": "TwitterDev"
隶属对象包含用户的详细信息’的隶属关系。可用于获取某个用户’的联盟徽章。
已确认_邮箱字符串已通过身份验证用户的已确认电子邮件地址。
连接_状态数组提供一个列表,说明正在进行身份验证的用户与被查询用户之间的关系,例如:正在关注、被其关注、已发送关注请求、已收到关注请求、已屏蔽、已静音

”连接_状态”: [
           “关注_请求_已收到”,
           “关注_请求_已发送”,
           “屏蔽中”,
           “已关注_作者”,
           “关注”,
           “静音”
]
可用于判断经过身份验证的用户与被查询用户之间的关联状态。
创建时间_于日期(ISO 8601)用户账户在 Twitter 上创建的 UTC 日期时间。

"created_at": "2013-12-14T04:35:55.000Z"
可用于判断某人使用 Twitter 的时间长度
说明字符串该用户的文本’用户的个人简介(亦称“bio”),如果该用户有提供的话。

"description": "X Dev 团队之声——关于 X API 的更新、新闻与活动的官方渠道。"
实体对象包含有关对用户具有特殊含义的文本的详细信息’的说明。

"entities": { <br/>       "url": { <br/>           "urls": [ <br/>               { <br/>                   "start": 0, <br/>                   "end": 23, <br/>                   "url": "https://t.co/3ZX3TNiZCY", <br/>                   "expanded_url": "/content/developer-twitter/en/community", <br/>                   "display_url": "developer.x.com/en/community" <br/>               } <br/>           ] <br/>       }, <br/>       "description": { <br/>           "urls": [ <br/>               { <br/>                   "start": 0, <br/>                   "end": 23, <br/>                   "url": "https://t.co/3ZX3TNiZCY", <br/>                   "expanded_url": "/content/developer-twitter/en/community", <br/>                   "display_url": "developer.x.com/en/community" <br/>               }, <br/>           "hashtags": [ <br/>               { <br/>                   "start": 23, <br/>                   "end": 30, <br/>                   "tag": "DevRel" <br/>               }, <br/>               { <br/>                   "start": 113, <br/>                   "end": 130, <br/>                   "tag": "BlackLivesMatter" <br/>               }, <br/>           "mentions": [ <br/>               { <br/>                   "start": 0, <br/>                   "end": 10, <br/>                   "tag": "TwitterDev" <br/>               }, <br/>           "cashtags": [ <br/>               { <br/>                   "start": 12, <br/>                   "end": 16, <br/>                   "tag": "twtr" <br/>               } <br/>           ] <br/>       } <br/>   }
Entities 是 JSON 对象,用于提供与描述相关的主题标签、链接、用户提及和现金标签的补充信息。有关详细信息,请参阅相应的实体。

所有用户开始索引为闭区间,而所有用户结束索引为左闭右开(不包含上界)。
是_身份_已验证布尔指示该用户是否已完成身份ID验证。
位置字符串用户所指定的位置’用户在其个人资料中填写的位置(如果有)。由于这是自由输入的值,可能并非有效位置,但在使用位置条件进行搜索时,可能会进行模糊匹配。

"location": "127.0.0.1"
大多数_最近_Tweet_id字符串该用户的唯一标识符’其最新的 Tweet。获取该用户的最新 Tweet。
仿作布尔指示该用户账户是否带有“Parody”标签。
已置顶_Tweet_id字符串该用户的唯一标识符’置顶的 Tweet。

"pinned_tweet_id": "1255542774432063488"
确定该用户个人资料页顶部置顶的 Tweet。可用于推断该用户的语言。
个人信息_横幅_URL字符串此用户的个人资料横幅图片的 URL,如显示在该用户主页上’的个人资料。

"profile_banner_url": "https://pbs.twimg.com/profile_banners/1716450569358098432/1721022977"
可用于下载此用户’的个人资料横幅。
个人资料_图像_url字符串此用户的个人资料图片的 URL,如同在其个人资料页中所示’的资料。

"profile_image_url": "https://pbs.twimg.com/profile_images/1267175364003901441/tBZNFAgA_normal.jpg"
可用于下载该用户的数据’的头像。
受保护布尔指示该用户是否选择保护其 Tweet(换言之,该用户的 Tweet 是否为受保护状态)‘s 的推文是私密的)。

"protected": false
公共_度量对象包含该用户的活动详情。

"public_metrics": {             "followers_count": 507902,             "following_count": 1863,             "tweet_count": 3561,             "listed_count": 1550         }
可用于评估某位 Twitter 用户的触达范围或影响力、量化其兴趣广度,以及衡量其在 Twitter 上的参与度。
接收_您的_私信布尔指示该用户是否接收来自已认证用户的私信(DM)‘的私信(DM)。
订阅对象包含该用户是否已订阅经过身份验证用户的详细信息。
订阅_media_key字符串表示已验证用户所持有的 X Premium 订阅类型的字符串。示例:基础高级PremiumPlus。将始终返回如果该用户不是已认证用户。
url字符串用户资料中指定的 URL(如果有)。‘如果有,则来自该用户的个人资料。

"url": "https://t.co/3ZX3TNiZCY"
Twitter 用户在其个人资料中提供的 URL。它可能是主页,但不一定是。
已验证布尔指示该用户是否为已验证的 Twitter 用户。

"verified": true
指示该 Twitter 用户的账户是否已通过验证。已验证账户可让公众了解该账户(具有公共利益)的真实性。
已验证_粉丝_计数器字符串表示某用户经验证关注者数量的字符串。
已验证_media_key字符串表示用户验证类型的字符串。例如:“蓝”,“业务”,“政府”
被扣留对象包含与被扣留内容相关的扣留详情(如适用)受限内容(如适用)。
检索用户对象 示例请求 在下面的请求中,我们在 users lookup 端点为该用户指定返回的 fields。请务必将 $BEARER_TOKEN 替换为你自己生成的 Bearer Token
  curl --request GET 'https://api.x.com/2/users?
  ids=2244994945&user.fields=created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,url,username,verified,withheld&expansions=pinned_tweet_id'
  --header 'Authorization: Bearer $BEARER_TOKEN'
  }
示例回复
    "data": [
        {
            "id": "2244994945",
            "name": "X 开发者",
            "username": "TwitterDev",
            "location": "127.0.0.1",
            "entities": {
                "url": {
                    "urls": [
                        {
                            "start": 0,
                            "end": 23,
                            "url": "https://t.co/3ZX3TNiZCY",
                            "expanded_url": "/content/developer-twitter/en/community",
                            "display_url": "developer.x.com/en/community"
                        }
                    ]
                },
                "description": {
                    "hashtags": [
                        {
                            "start": 23,
                            "end": 30,
                            "tag": "DevRel"
                        },
                        {
                            "start": 113,
                            "end": 130,
                            "tag": "BlackLivesMatter"
                        }
                    ]
                }
            },
            "verified": true,
            "description": "X 开发者关系团队的官方声音,为您提供有关 X API 更新、新闻和活动的官方信息来源。\n\n#BlackLivesMatter",
            "url": "https://t.co/3ZX3TNiZCY",
            "profile_image_url": "https://pbs.twimg.com/profile_images/1267175364003901441/tBZNFAgA_normal.jpg",
            "protected": false,
            "pinned_tweet_id": "1255542774432063488",
            "created_at": "2013-12-14T04:35:55.000Z"
        }
    ],
    "includes": {
        "tweets": [
            {
                "id": "1255542774432063488",
                "text": "在这个前所未有的时期,X 上正在发生的事情可以帮助全世界更好地理解和应对疫情。\n\n我们正在推出免费的 COVID-19 流式端点,让符合条件的开发者和研究人员能够实时研究公共对话。https://t.co/BPqMcQzhId"
            }
        ]
    }
}

Space

Spaces 通过实时音频对话实现表达与互动。Space 数据字典包含与 Space 相关的元数据;所有细节都会实时更新。 User 对象可在 user 资源中查找并展开。通过在 expansions 查询参数中添加至少一个 host_idscreator_idspeaker_idsmentioned_user_ids,即可展开这些对象。 与 Tweet 不同,Spaces 具有时效性,在结束后或被创建者取消时将不可用。当你的应用处理 Spaces 数据时,你需要返回最新信息,并且必须移除平台上已不再可用的数据。Spaces 查找端点可帮助你确保尊重用户的期望和意图。
Field ValueTypeDescriptionHow it can be used
id (default)string请求的 Space 的唯一标识符。
"id": "1zqKVXPQhvZJB"
唯一标识响应中返回的 Space。
state (default)string指示该 Space 已开始、将开始或已结束。
"state": "live"
筛选正在进行或已排期的 Spaces。
created_atdate (ISO 8601)此 Space 的创建时间。
"created_at": "2021-07-04T23:12:08.000Z"
了解 Space 的创建时间并按时间排序。
creator_idstringSpace 创建者的唯一标识符。
"creator_id": "2244994945"
ended_atdate (ISO 8601)Space 的结束时间(如适用)。
"ended_at": "2021-07-04T00:11:44.000Z"
确定直播 Space 的结束时间以计算持续时长。
host_idsarraySpace 主持人的唯一标识符。
"host_ids": ["2244994945", "6253282"]
展开 User 对象,了解互动情况。
langstringSpace 的语言(如检测到)。
"lang": "en"
按语言对 Spaces 进行分类。
is_ticketedboolean指示是否为售票 Space。
"is_ticketed": false
突出显示感兴趣的内容。
invited_user_idsarray被邀请为发言者的用户 ID 列表。
"invited_user_ids": ["2244994945", "6253282"]
展开 User 对象,了解互动情况。
participant_countintegerSpace 中的用户数量,包括主持人和发言者。
"participant_count": 420
了解互动情况,生成报告。
subscriber_countinteger为某个 Space 设置提醒的人数。
"subscriber_count": 36
了解活动关注度。
scheduled_startdate (ISO 8601)Space 的计划开始时间。
"scheduled_start": "2021-07-14T08:00:00.000Z"
与日历通知集成。
speaker_idsarray任意时间点发言的用户列表。
"speaker_ids": ["2244994945", "6253282"]
展开 User 对象,了解互动情况。
started_atdate (ISO 8601)Space 的实际开始时间。
"started_at": "2021-07-14T08:00:12.000Z"
确定 Space 的开始时间。
titlestringSpace 的标题。
"title": "Say hello to the Space data object!"
分析关键词、话题标签和提及。
topic_idsarray由 Space 创建者选择的话题 ID。
"topic_ids": ["2244994945", "6253282"]
分析关键词、话题标签和提及。
iddate (ISO 8601)Space 元数据的最后更新时间。
"updated_at": "2021-07-11T14:44:44.000Z"
保持信息为最新。
检索 Space 对象 示例请求 在以下请求中,我们在Spaces 查询端点上为该 Space 指定了返回的 fields。请务必将 $BEARER_TOKEN 替换为你自己生成的 Bearer Token
curl "https://api.x.com/2/spaces/1DXxyRYNejbKM?space.fields=created_at,creator_id,created_athost_ids,lang,is_ticketed,invited_user_ids,participant_count,scheduled_start,speaker_ids,started_at,state,title,updated_at&expansions=creator_id,host_ids,invited_user_ids,speaker_ids" --header "Authorization: Bearer $BEARER_TOKEN"
** 示例响应 **
{
  "data": {
    "id": "1zqKVXPQhvZJB",
    "state": "live",
    "created_at": "2021-07-04T23:12:08.000Z",
    "host_ids": [
      "2244994945",
      "6253282"
    ],
    "lang": "en",
    "is_ticketed": false,
    "invited_user_ids": [
      "2244994945",
      "6253282"
    ],
    "participant_count": 420,
    "scheduled_start": "2021-07-14T08:00:00.000Z",
    "speaker_ids": [
      "2244994945",
      "6253282"
    ],
    "started_at": "2021-07-14T08:00:12.000Z",
    "title": "向 Space 数据对象问好!",
    "updated_at": "2021-07-11T14:44:44.000Z"
  },
  "includes": {
    "users": [
      {
        "id": "2244994945",
        "name": "Twitter Dev",
        "username": "TwitterDev"
      },
      {
        "id": "6253282",
        "name": "Twitter API",
        "username": "TwitterAPI"
      }
    ]
  }
}

列表

List 对象包含用于描述所引用 List 的 Twitter Lists 元数据。List 对象是在 List 查询端点中返回的主要对象。在该端点请求其他 List 字段时,只需使用字段参数 list.fields List 对象不会作为其他数据对象的子对象出现。不过,可以在用户资源中找到并展开用户对象。通过在 expansions 查询参数中添加 owner&#95;id,这些对象即可用于扩展。在请求其他字段以完善主要的 List 对象时,将此扩展与 list.fields 字段参数一起使用,并使用 user.fields 来完善扩展对象。
字段值类型说明用途
id(默认)string此 List 的唯一标识符。
"id": "2244994945"
用于以编程方式检索特定 List 的信息。
name(默认)string创建 List 时指定的名称。
"name": "Twitter Lists"
created_atdate (ISO 8601)创建该 List 的 UTC 日期时间。
"created_at": "2013-12-14T04:35:55.000Z"
用于判断某个 List 在 Twitter 上存在了多长时间。
descriptionstring向用户说明该 List 的简要描述。
"description": "People that are active members of the Bay area cycling community on Twitter."
follower_countinteger关注此 List 的用户数量。
"follower_count": 198
member_countinteger此 List 的成员数量。
"member_count": 60
privateboolean指示该 List 是否为私密。
"private": false
owner_idstring此 List 所有者的唯一标识符。
"owner_id": "1255542774432063488"
可用于判断该用户是否拥有其他 List,并展开 User 对象。
检索 User 对象 示例请求 在以下请求中,我们在 根据 ID 查询 List 端点请求用户字段。将 $BEARER_TOKEN 替换为你生成的 Bearer Token
curl --request GET 'https://api.x.com/2/lists/1355797419175383040?list.fields=created_at,description,private,follower_count,member_count,owner_id&expansions=owner_id' --header 'Authorization: Bearer $BEARER_TOKEN'
** 示例响应 **
{
  "data": {
    "name": "Twitter Comms",
    "member_count": 60,
    "id": "1355797419175383040",
    "private": false,
    "description": "",
    "follower_count": 198,
    "owner_id": "257366942",
    "created_at": "2021-01-31T08:37:48.000Z"
  },
  "includes": {
    "users": [
      {
        "created_at": "2011-02-25T07:51:26.000Z",
        "name": "Ashleigh Hay 🤸🏼‍♀️",
        "id": "257366942",
        "username": "shleighhay",
        "verified": false
      }
    ]
  }
}

媒体

媒体指附加到 Tweet 的任何图像、GIF 或视频。media 对象不是任何端点的主对象,但可以在 Tweet 对象中找到并通过扩展包含。使用 ?expansions=attachments.media_keys 可展开以获取仅包含默认字段的精简对象。请求更多字段以补全对象时,将该扩展与字段参数 media.fields 搭配使用。
字段值类型说明用途
media_key(默认)string已展开媒体内容的唯一标识符。
"media_key": "13_1263145212760805376"
可用于以编程方式检索媒体
type(默认)string内容类型(animated_gif、photo、video)。
"type": "video"
将媒体归类为照片、GIF 或视频
urlstring指向 Twitter 上媒体文件的直接 URL。对于照片,返回带有 URL 字段的 Media 对象
duration_msinteger当 type 为 video 时提供。视频时长(毫秒)。
"duration_ms": 46947
heightinteger此内容的高度(像素)。
"height": 1080
non_public_metricsobject请求时刻的媒体内容非公开互动指标。需要用户上下文认证。
"non_public_metrics": { "playback_0_count": 1561, "playback_100_count": 116, "playback_25_count": 559, "playback_50_count": 305, "playback_75_count": 183,}
判断视频互动:有多少用户分别观看到视频的四分之一区间。
organic_metricsobject在自然场景中跟踪的媒体内容互动指标,取请求时刻。需要用户上下文认证。
"organic_metrics": { "playback_0_count": 1561, "playback_100_count": 116, "playback_25_count": 559, "playback_50_count": 305, "playback_75_count": 183, "view_count": 629}
判断媒体的自然互动。
preview_image_urlstring此内容的静态占位预览图 URL。
"preview_image_url": "https://pbs.twimg.com/media/EYeX7akWsAIP1_1.jpg"
promoted_metricsobject在推广场景中跟踪的媒体内容互动指标,取请求时刻。需要用户上下文认证。
"promoted_metrics": { "playback_0_count": 259, "playback_100_count": 15, "playback_25_count": 113, "playback_50_count": 57, "playback_75_count": 25, "view_count": 124}
判断 Tweet 被推广时的媒体互动。
public_metricsobject请求时刻的媒体内容公开互动指标。
"public_metrics": { "view_count": 6865141}
判断附加到该 Tweet 的视频的总观看次数。
widthinteger此内容的宽度(像素)。
"width": 1920
alt_textstring用于无障碍的图像描述。最长 1000 个字符。目前仅可为图像添加替代文本。
"alt_text": "Rugged hills along the Na Pali coast on the island of Kauai"
供视障用户查看时提供图像的文字说明。
variantsarray每个媒体对象可能具有多个显示或播放版本,分辨率或格式各异。
"variants": [{ "bit_rate": 632000, "content_type": "video/mp4", "url": "https://video.twimg.com/ext_tw_video/1527322141724532740/pu/vid/320x568/lnBaR2hCqE-R_90a.mp4?tag=12"}]
检索 media 对象 示例请求 在以下请求中,我们在 Tweet lookup 端点请求为附加到 Tweet 的媒体对象返回相应的 fields。由于媒体是 Tweet 的子对象,因此必须使用 attachment.media_keys 扩展。请务必将 $BEARER_TOKEN 替换为你自己生成的 Bearer Token
curl --request GET 'https://api.x.com/2/tweets?ids=1263145271946551300&expansions=attachments.media_keys&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text' --header 'Authorization: Bearer $BEARER_TOKEN'
{
  "data": [
    {
      "text": "测试,测试...\n\n一种全新的方式,让你只与想聊的人对话。我们将先在全球范围内小范围上线,敬请留意,看看它的实际表现。https://t.co/pV53mvjAVT",
      "id": "1263145271946551300",
      "attachments": {
        "media_keys": [
          "13_1263145212760805376"
        ]
      }
    }
  ],
  "includes": {
    "media": [
      {
        "duration_ms": 46947,
        "type": "video",
        "height": 1080,
        "media_key": "13_1263145212760805376",
        "public_metrics": {
          "view_count": 6909260
        },
        "preview_image_url": "https://pbs.twimg.com/media/EYeX7akWsAIP1_1.jpg",
        "width": 1920
      }
    ]
  }
}

投票

包含在 Tweet 中的投票不是任何端点上的主对象,但可在 Tweet 对象中找到并展开。可通过 ?expansions=attachments.poll_ids 进行展开,以获取仅包含默认字段的精简对象。在请求附加字段以完善该对象时,请将该 expansion 与字段参数 poll.fields 一起使用。
字段值类型说明
id(默认)string已展开投票的唯一标识符。
{"id": "1199786642791452673"}
options(默认)array包含描述所引用投票中每个选项的对象。
{"options": [ { "position": 1, "label": "“C Sharp”", "votes": 795 }, { "position": 2, "label": "“C Hashtag”", "votes": 156 } ]}
duration_minutesinteger指定此投票的总持续时长。
{"duration_minutes": 1440}
end_datetimedate (ISO 8601)指定此投票的结束日期和时间。
{"end_datetime": "2019-11-28T20:26:41.000Z"}
voting_statusstring指示此投票是否仍处于活动状态且可继续投票,或投票是否已关闭。
{"voting_status": "closed"}
检索投票对象 示例请求 在以下请求中,我们在 Tweets lookup 端点为附加在 Tweet 上的投票对象请求字段。由于投票是 Tweet 的子对象,因此需要使用 attachments.poll_id expansion。请务必将 $BEARER_TOKEN 替换为你自行生成的 Bearer Token
curl --request GET 'https://api.x.com/2/tweets?ids=1199786642791452673&expansions=attachments.poll_ids&poll.fields=duration_minutes,end_datetime,id,options,voting_status' --header 'Authorization: Bearer $BEARER_TOKEN'
示例响应
{
  "data": [
    {
      "text": "C#",
      "id": "1199786642791452673",
      "attachments": {
        "poll_ids": [
          "1199786642468413448"
        ]
      }
    }
  ],
  "includes": {
    "polls": [
      {
        "id": "1199786642468413448",
        "voting_status": "closed",
        "duration_minutes": 1440,
        "options": [
          {
            "position": 1,
            "label": "“C Sharp”",
            "votes": 795
          },
          {
            "position": 2,
            "label": "“C Hashtag”",
            "votes": 156
          }
        ],
        "end_datetime": "2019-11-28T20:26:41.000Z"
      }
    ]
  }
}

地点

在任何端点上,Tweet 中标记的地点并非主对象,但可在 Tweet 资源中找到并通过扩展获取。可使用 ?expansions=geo.place_id 获取仅包含默认字段的精简对象。若需请求更多字段以完善该对象,请将该扩展与字段参数 place.fields 一起使用。
字段值类型说明用途
full_name(默认)string更长、更详细的地点名称。按特定地点名称对 Tweet 进行分类
"full_name": "Manhattan, NY"
id(默认)string若 Tweet 中标记的是兴趣点,则为所扩展地点的唯一标识符。使用此值以编程方式检索地点
"id": "01a9a39529b27f36"
contained_withinarray返回包含所引用地点的已知地点的标识符。
countrystring此地点所属国家的全称。按国家名称对 Tweet 进行分类
"country": "United States"
country_codestring此地点所属国家的 ISO Alpha-2 国家/地区代码。按国家/地区代码对 Tweet 进行分类
"country_code": "US"
geoobject以 GeoJSON 格式包含地点详情。
`json
”geo”:
“type”: “Feature”,
“bbox”: [
-74.026675,
40.683935,
-73.910408,
40.877483
],
“properties”:
}
`
namestring此地点的简称。按特定地点名称对 Tweet 进行分类
"name": "Manhattan"
place_typestring指明该地点信息所表示的具体类型,例如城市名称或兴趣点。按特定地点类型对 Tweet 进行分类
"place_type": "city"
检索地点对象 示例请求 在以下请求中,我们在 Tweets lookup 端点请求附加在该 Tweet 上的地点对象字段。由于地点是 Tweet 的子对象,必须使用 geo.place_id 扩展。请务必将 $BEARER_TOKEN 替换为你自己生成的 Bearer Token
curl --request GET 'https://api.x.com/2/tweets?ids=1136048014974423040&expansions=geo.place_id&place.fields=contained_within,country,country_code,full_name,geo,id,name,place_type' --header 'Authorization: Bearer $BEARER_TOKEN'
示例回复
{
  "data": [
    {
      "text": "我们正在分享新 Twitter Developer Labs 计划的实时演示,由我们 DevRel 团队成员 @jessicagarson 主持 #TapIntoTwitter https://t.co/ghv7f4dW5M",
      "id": "1136048014974423040",
      "geo": {
        "place_id": "01a9a39529b27f36"
      }
    }
  ],
  "includes": {
    "places": [
      {
        "geo": {
          "type": "Feature",
          "bbox": [
            -74.026675,
            40.683935,
            -73.910408,
            40.877483
          ],
          "properties": {}
        },
        "country_code": "US",
        "name": "Manhattan",
        "id": "01a9a39529b27f36",
        "place_type": "city",
        "country": "美国",
        "full_name": "Manhattan, NY"
      }
    ]
  }
}

私信事件

私信(DM)会话由事件组成。X API v2 当前支持三种事件类型:MessageCreate、ParticipantsJoin 和 ParticipantsLeave。 DM 事件对象由私信查询端点返回;通过管理私信端点成功创建私信时,会生成一个 MessageCreate 事件。 请求 DM 事件时,默认会包含三个事件对象属性(字段):id、event_type 和 text。若需接收更多事件字段,请使用 fields 参数 dm_event.fields 进行选择。其他可用的事件字段包括:dm_conversation_id、created_at、sender_id、attachments、participant_ids 和 referenced_tweets。 其中有多个字段提供与该私信事件相关的其他 X 对象的 ID:
  • sender_id - 发送消息的账号 ID,或将参与者邀请至群组会话的账号 ID
  • partricipants_ids - 账号 ID 的数组。对于 ParticipantsJoin 和 ParticipantsLeave 事件,此数组将包含创建该事件的账号的单个 ID
  • attachments - 提供发送者在 Twitter 上传内容的媒体 ID
  • referenced_tweets - 如果在 text 字段中检测到 Tweet URL,响应中会包含该 Tweet 的 ID
可使用 sender_id、participant_ids、referenced_tweets.id 和 attachments.media_keys 的 expansions 来展开这些 Twitter 对象 ID。
字段值类型说明使用方式
id (默认)string事件的唯一标识符。

“id”: “1050118621198921728”
用于以编程方式检索特定会话事件(适用于 v1.1 端点)。
event_type (默认)string描述事件类型。目前支持三种类型: 

* MessageCreate

* ParticipantsJoin

* ParticipantsLeave


“event_type”: “MessageCreate”
在检索会话历史时,用于了解消息的创建时间;对于群组会话,用于了解参与者加入和离开的时间。所有 GET 方法都支持使用 event_type= 查询参数过滤特定事件类型。
text (默认)string私信的实际 UTF-8 文本。 

“text”: “Hello, just you!”
搭配聊天机器人,可用于分析消息内容并确定自动回复;也可用于构建会话搜索功能。
entitiesobject从私信文本中解析出的实体。提供关于话题标签、URL、提及等的更多信息。
sender_idstring创建该事件的用户 ID。要在响应中展开此对象,请将 sender_id 作为 expansion 包含,并使用 user.fields 查询参数指定所需的用户对象属性。

“sender_id”: “906948460078698496”
检索创建 MessageCreate 或 ParticipantsJoin 事件的用户对象。
participant_idsarray (of strings)加入和离开群组会话的参与者 ID。创建新的群组会话时也会使用。要在响应中展开此对象,请将 participant_ids 作为 expansion 包含,并使用 user.fields 查询参数指定所需的用户对象属性。

“participant_ids”: [

     “906948460078698496”

]
用于检索加入和离开群组会话的参与者的用户对象。
dm_conversation_idstring该事件所属会话的唯一标识符。

“dm_conversation_id”: “1584988213961031680”
用于以编程方式从某个会话中检索事件,并向该会话添加私信。
created_atdate (ISO 8601)Tweet 的创建时间(UTC)。

“created_at”: “2019-06-04T23:12:08.000Z”
可用于了解私信的创建时间或会话参与者加入或离开的时间。
referenced_tweetsarray私信文本中提到的任何 Tweet 的 ID。要在响应中展开此对象,请将 referenced_tweets.id 作为 expansion 包含,并使用 tweet.fields 查询参数指定所需的 Tweet 对象属性。

“referenced_tweets”: [

   

“id”: “1578868150510456833”

   

]
当私信引用了 Tweet 时,可使用这些 ID 查询该 Tweet 的详细信息。
attachmentsobject对于带有媒体的私信,提供已上传内容(照片、视频或 GIF)的 media key。要在响应中展开此对象,请将 attachments.media_keys 作为 expansion 包含,并使用 media.fields 查询参数指定所需的媒体对象属性。目前支持一个附件。 

“attachments”:

    “media_keys”: [

        “3_1136048009270239232”

    ]

用于了解附加在私信中的媒体对象。
检索私信事件对象 示例请求 在本示例中,我们将构建一个请求,以检索与一对一会话相关的事件。该请求将返回基础的私信事件字段,以及引用的 Tweet 及其作者的附加字段。我们将构建一个查询,请求以下内容:
  • 基础事件属性,例如其创建时间以及所属的会话(dm_conversation)。
  • 发送私信者的账户 ID 和描述。
  • 任何被引用的 Tweet 的文本以及其发布时间。
  • 任何被引用的 Tweet 作者的账户 ID 和描述。
要返回这些属性,您的请求查询应包含以下内容: ?dm_event.fields=id,sender&#95;id,text,created_at,dm_conversation_id&expansions=sender&#95;id,referenced_tweets.id&tweet.fields=created_at,text,author_id&user.fields=description
      curl --request GET 'https://api.x.com/2/dm_conversations/with/:participant_id/dm_events?tweet.fields=created_at,text,author_id&user.fields=description&expansions=sender_id,participant_ids,referenced_tweets.id&dm_event.fields=id,sender_id,text,participant_ids,created_at,'
    --header 'Authorization: Bearer $BEARER_TOKEN'
请务必将 $BEARER_TOKEN 替换为你自行生成的 Bearer Token 示例响应
      {
	"data": [{
			"id": "1585047616894574596",
			"sender_id": "944480690",
			"text": "你好,就你一个人!",
			"created_at": "2022-10-25T23:16:15.000Z",
			"event_type": "MessageCreate",
			"dm_conversation_id": "944480690-906948460078698496"
		},
		{
			"id": "1581048670673260549",
			"sender_id": "944480690",
			"text": "简单的 Tweet 链接:https://t.co/IYFbRIdXHg",
			"referenced_tweets": [{
				"id": "1578900353814519810"
			}],
			"created_at": "2022-10-14T22:25:52.000Z",
			"event_type": "MessageCreate",
			"dm_conversation_id": "944480690-906948460078698496"
		},
		{
			"id": "1580705121553420292",
			"sender_id": "944480690",
			"text": "添加一条新的一对一私信。",
			"created_at": "2022-10-13T23:40:43.000Z",
			"event_type": "MessageCreate",
			"dm_conversation_id": "944480690-906948460078698496"
		}
	],
	"includes": {
		"users": [{
				"name": "API Demos",
				"description": "托管 TwitterDev 集成...@TwitterDev #DevRel",
				"id": "944480690",
				"username": "FloodSocial"
			},
			{
				"name": "the SnowBot",
				"description": "@TwitterDev SnowBot 的主页...提供雪况报告、雪景照片和雪地研究链接...聊天机器人目前正在为 Twitter APIv2 进行改造。",
				"id": "906948460078698496",
				"username": "SnowBotDev"
			}
		],
		"tweets": [{
				"text": "有点遗憾没有祝大家科罗拉多新水年快乐……\n\n祝所有科罗拉多的朋友和同事们新水年快乐,无论新老……\n\n愿这是一个丰沛的水年,但也不要太过丰沛……",
				"id": "1578900353814519810",
				"created_at": "2022-10-09T00:09:13.000Z",
				"author_id": "944480690",
				"edit_history_tweet_ids": [
					"1578900353814519810"
				]
			}
		]
	},
	"meta": {
		"result_count": 3,
		"next_token": "18LAA581J5II7LA00C00ZZZZ",
		"previous_token": "1BLC45G1H8CAL5DG0G00ZZZZ"
	}
}

社区

社区是 X 用户联结、分享,并更贴近其最关心话题讨论的专属空间。 社区中的帖子对所有 X 用户可见,但只有该社区内的成员才能参与互动与讨论。 Community 对象包含与社区相关的元数据。
字段值类型描述
created_atdate (ISO 8601)社区的创建时间。
idstring社区的唯一标识符。
namestring社区名称。
descriptionstring社区的描述文本(如有)。
accessstring社区的访问级别。

可能的取值:
- Public
- Closed
join_policystring社区的加入策略。

可能的取值:
- Open
- RestrictedJoinRequestsDisabled
- RestrictedJoinRequestsRequireAdminApproval
- RestrictedJoinRequestsRequireModeratorApproval
- SuperFollowRequired
member_countinteger已加入该社区的成员数。
检索 Community 对象 示例请求 在以下请求中,我们在基于给定关键词搜索社区列表的同时请求特定字段。请确保将 $BEARER_TOKEN 替换为你自行生成的 Bearer Token
curl --location 'https://api.x.com/2/communities/search?query=anime&amp;community.fields=access,created_at,description,id,join_policy,member_count,name' --header 'Authorization: $BEARER_TOKEN'
示例回复
{
  "data": [
    {
      "id": "Q29tbXVuaXR5OjE3NTg3NDc4MTc2NDI3MDA5MjI=",
      "description": "欢迎来到动漫社区!这里是动漫爱好者聚集分享喜爱作品、畅谈动漫话题的地方。",
      "join_policy": "开放",
      "access": "公开",
      "member_count": 39915,
      "name": "动漫社区",
      "created_at": "2024-02-17T06:58:50.000Z"
    },
    {
      "id": "Q29tbXVuaXR5OjE1MDY3OTM5NTMxMDYwNDI4OTE=",
      "description": "加入我们,一起聊动漫 🥰",
      "join_policy": "开放",
      "access": "公开",
      "member_count": 26019,
      "name": "动漫世界 🌸",
      "created_at": "2022-03-24T00:44:07.000Z"
    },
    {
      "id": "Q29tbXVuaXR5OjE0OTY3NzYyMTU5Mzk1MzQ4NDk=",
      "description": "为所有动漫爱好者和创作者打造!",
      "join_policy": "开放",
      "access": "公开",
      "member_count": 5612,
      "name": "动漫",
      "created_at": "2022-02-24T09:17:13.000Z"
    }
  ],
  "meta": {
    "next_token": "7140dibdnow9c7btw481s8m561gat797rboud5r80xvzm"
  }
}

如何使用 fields 和 expansions

默认情况下,如果未使用 fieldsexpansions 参数发出请求,X API v2 的数据对象只会包含少量默认字段。本指南将演示如何在请求中使用 fieldsexpansions 查询参数,以便在响应中获取额外的对象和字段。 在本指南中,我们将基于下方的 Tweet 截图请求多个字段。   该图像为 @X 发布的 Tweet 截图。你可以看到 Tweet 文本、用户名、发布时间与时间、来源以及公开指标。它还包含一个视频。 如截图所示,存在多项与 Tweet 相关的可见信息,包括 Tweet 作者、Tweet 指标、创建时间戳、视频以及视频观看次数。还有一些数据在截图中不可见,但仍可通过请求获取。  在向 API 发出请求时,默认响应较为精简,仅包含默认的 Tweet 字段(id 和 text)。你也只会收到所使用端点返回的主要对象,而不会包含可能与该主要对象相关的任何关联数据对象。 这种精简性,加上 fields 和 expansions 参数,使你能够根据用例仅请求所需的字段。   

请求其他字段和对象。

首先,我们将使用 Tweet ID 和 GET /tweets 端点请求一个 Tweet 对象 请求:
curl --request GET --url 'https://api.x.com/2/tweets?ids=1260294888811347969' \
  --header 'Authorization: Bearer $BEARER_TOKEN'
Response:
{
    "data": [
        {
            "id": "1260294888811347969",
            "text": "不要错过关于您 Tweet 的讨论。\n\n现在在 iOS 上,您可以在一处查看所有带评论的转发。https://t.co/oanjZfzC6y"
        }
    ]
}
以下分步指南将向您展示如何检索屏幕截图中可见的附加数据。
  1. 通过查看我们的对象模型或各端点的 API 参考页面中的字段列表,识别你希望请求的其他字段。 在本例中,我们将请求以下附加字段: attachments、author_id、created_at、public_metrics。
  2. 使用逗号分隔的列表,将上述字段作为值来构建 tweet.fields 查询参数: ?tweet.fields=attachments,author_id,created_at,public_metrics
  3. 将该查询参数添加到你之前发出的 GET /tweets 请求中。
请求: curl --request GET --url 'https://api.x.com/2/tweets?ids=1260294888811347969&tweet.fields=attachments,author_id,created_at,public_metrics' \ --header 'Authorization: Bearer $BEARER_TOKEN' Response:
{
    "data": [
        {
            "id": "1260294888811347969",
            "text": "不要错过关于你 Tweet 的其他 Tweets。\n\n现在在 iOS 上,你可以在一处查看所有带评论的转推。https://t.co/oanjZfzC6y",
            "author_id": "783214",
            "public_metrics": {
                "retweet_count": 5219,
                "reply_count": 1828,
                "like_count": 17141,
                "quote_count": 3255
            },
            "attachments": {
                "media_keys": [
                    "13_1260294804770041858"
                ]
            },
            "created_at": "2020-05-12T19:44:51.000Z"
        }
    ]
}
  1. 接下来,我们将请求 Tweet 中包含的视频相关字段。为此,我们将使用 expansions 参数,将 attachments.media_keys 作为值,并将其添加到请求中。
?expansions=attachments.media_keys 请求:
curl --request GET --url 'https://api.x.com/2/tweets?ids=1260294888811347969&tweet.fields=attachments,author_id,created_at,public_metrics&expansions=attachments.media_keys' \
  --header 'Authorization: Bearer $BEARER_TOKEN'
响应,媒体对象在 includes 对象中呈现:
{
    "data": [
        {
            "id": "1260294888811347969",
            "text": "不要错过关于您 Tweet 的讨论。\n\n现在在 iOS 上,您可以在一处查看所有带评论的转推。https://t.co/oanjZfzC6y",
            "public_metrics": {
                "retweet_count": 5219,
                "reply_count": 1828,
                "like_count": 17141,
                "quote_count": 3255
            },
            "created_at": "2020-05-12T19:44:51.000Z",
            "attachments": {
                "media_keys": [
                    "13_1260294804770041858"
                ]
            },
            "author_id": "783214"
        }
    ],
    "includes": {
        "media": [
            {
                "media_key": "13_1260294804770041858",
                "type": "video"
            }
        ]
    }
}
  1. 最后,我们将请求视频的观看次数和时长。这些不是默认字段,因此需要明确指定。在请求中使用 media.fields 参数,传入以逗号分隔的值:public_metricsduration_ms
?media.fields=public_metrics,duration_ms 请求:   curl --request GET --url 'https://api.x.com/2/tweets?ids=1260294888811347969&tweet.fields=attachments,author_id,created_at,public_metrics&expansions=attachments.media_keys&media.fields=duration_ms,public_metrics' --header 'Authorization: Bearer $BEARER_TOKEN' 响应中现在包含了在 Tweet 截图中可见的所有 data:
  {
    "data": [
        {
            "id": "1260294888811347969",
            "text": "不要错过关于您 Tweet 的讨论。\n\n现在在 iOS 上,您可以在一处查看所有带评论的转推。https://t.co/oanjZfzC6y",
            "author_id": "783214",
            "public_metrics": {
                "retweet_count": 5219,
                "reply_count": 1828,
                "like_count": 17141,
                "quote_count": 3255
            },
            "created_at": "2020-05-12T19:44:51.000Z",
            "attachments": {
                "media_keys": [
                    "13_1260294804770041858"
                ]
            }
        }
    ],
    "includes": {
        "media": [
            {
                "duration_ms": 36503,
                "media_key": "13_1260294804770041858",
                "public_metrics": {
                    "view_count": 1534703
                },
                "type": "video"
            }
        ]
    }
}
总计,我们在此示例中包含了以下参数:
  • ids=1260294888811347969
  • tweet.fields=attachments,author_id,created_at,public_metrics
  • expansions=attachments.media_keys
  • media.fields=public_metrics,duration_ms  
将它们合并后,完整的查询字符串如下:
?ids=1260294888811347969&tweet.fields=attachments,author\_id,created\_at,public\_metrics&expansions=attachments.media\_keys&media.fields=public\_metrics,duration\_ms

X API v2 示例载荷

Tweet

{
  "data": [
    {
      "conversation_id": "1304102743196356610",
      "id": "1307025659294674945",
      "possibly_sensitive": false,
      "public_metrics": {
        "retweet_count": 11,
        "reply_count": 2,
        "like_count": 70,
        "quote_count": 1
      },
      "entities": {
        "urls": [
          {
            "start": 74,
            "end": 97,
            "url": "https://t.co/oeF3ZHeKQQ",
            "expanded_url": "https://dev.to/twitterdev/understanding-the-new-tweet-payload-in-the-twitter-api-v2-1fg5",
            "display_url": "dev.to/twitterdev/und…",
            "images": [
              {
                "url": "https://pbs.twimg.com/news_img/1317156296982867969/2uLfv-Bh?format=jpg&name=orig",
                "width": 1128,
                "height": 600
              },
              {
                "url": "https://pbs.twimg.com/news_img/1317156296982867969/2uLfv-Bh?format=jpg&name=150x150",
                "width": 150,
                "height": 150
              }
            ],
            "status": 200,
            "title": "了解 X API v2 中的新 Tweet 数据结构",
            "description": "X 最近发布了全新的 X API v2,从零开始重构以提供新功能...",
            "unwound_url": "https://dev.to/twitterdev/understanding-the-new-tweet-payload-in-the-twitter-api-v2-1fg5"
          }
        ]
      },
      "text": "这篇文章重点介绍了新 Tweet 数据结构 v2 的更新内容 https://t.co/oeF3ZHeKQQ",
      "in_reply_to_user_id": "2244994945",
      "created_at": "2020-09-18T18:36:15.000Z",
      "author_id": "2244994945",
      "referenced_tweets": [
        {
          "type": "replied_to",
          "id": "1304102743196356610"
        }
      ],
      "lang": "en",
      "source": "Twitter Web App"
    }
  ],
  "includes": {
    "users": [
      {
        "created_at": "2013-12-14T04:35:55.000Z",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1283786620521652229/lEODkLTh_normal.jpg",
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.x.com/en/community",
                "display_url": "developer.x.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "id": "2244994945",
        "verified": true,
        "location": "127.0.0.1",
        "description": "#TwitterDev 团队的官方账号,为您提供与 #TwitterAPI 相关的更新、资讯和活动信息。",
        "pinned_tweet_id": "1293593516040269825",
        "username": "TwitterDev",
        "public_metrics": {
          "followers_count": 513961,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "name": "Twitter Dev",
        "url": "https://t.co/3ZX3TNiZCY",
        "protected": false
      }
    ],
    "tweets": [
      {
        "conversation_id": "1304102743196356610",
        "id": "1304102743196356610",
        "possibly_sensitive": false,
        "public_metrics": {
          "retweet_count": 31,
          "reply_count": 12,
          "like_count": 104,
          "quote_count": 4
        },
        "entities": {
          "mentions": [
            {
              "start": 146,
              "end": 158,
              "username": "suhemparack"
            }
          ],
          "urls": [
            {
              "start": 237,
              "end": 260,
              "url": "https://t.co/CjneyMpgCq",
              "expanded_url": "https://x.com/TwitterDev/status/1304102743196356610/video/1",
              "display_url": "pic.x.com/CjneyMpgCq"
            }
          ],
          "hashtags": [
            {
              "start": 8,
              "end": 19,
              "tag": "TwitterAPI"
            }
          ]
        },
        "attachments": {
          "media_keys": [
            "13_1303848070984024065"
          ]
        },
        "text": "新的 #TwitterAPI 对 Tweet 数据结构进行了一些改进。您可能想知道——主要有哪些不同?🧐\n\n在这个视频中,@SuhemParack 对比了 v1.1 Tweet 数据结构与我们 v2 端点返回的内容。https://t.co/CjneyMpgCq",
        "created_at": "2020-09-10T17:01:37.000Z",
        "author_id": "2244994945",
        "lang": "en",
        "source": "Twitter Media Studio"
      }
    ]
  }
}

Tweet 回复

{
  "data": [
    {
      "lang": "en",
      "conversation_id": "1296887091901718529",
      "text": "了解 @PennMedCDH 如何使用 Twitter 数据来理解 COVID-19 健康危机 📊\n\nhttps://t.co/1tdA8uDWes",
      "referenced_tweets": [
        {
          "type": "replied_to",
          "id": "1296887091901718529"
        }
      ],
      "possibly_sensitive": false,
      "entities": {
        "annotations": [
          {
            "start": 30,
            "end": 36,
            "probability": 0.6318,
            "type": "Product",
            "normalized_text": "Twitter"
          }
        ],
        "mentions": [
          {
            "start": 8,
            "end": 19,
            "username": "PennMedCDH"
          }
        ],
        "urls": [
          {
            "start": 87,
            "end": 110,
            "url": "https://t.co/1tdA8uDWes",
            "expanded_url": "https://developer.x.com/en/use-cases/success-stories/penn",
            "display_url": "developer.x.com/en/use-cases/s…",
            "status": 200,
            "title": "宾夕法尼亚大学医学院数字健康中心",
            "description": "宾夕法尼亚大学医学院数字健康中心创建了一个 COVID-19 Twitter 地图,其中包括详细展示情绪、报告症状、各州数据细分以及 COVID-19 疫情边境数据的图表。此外,他们的 Penn Med With You 计划使用来自 Twitter 的区域汇总信息为其网站和短信服务提供信息支持。该服务利用这些信息传播相关且及时的资源。",
            "unwound_url": "https://developer.x.com/en/use-cases/success-stories/penn"
          }
        ]
      },
      "id": "1296887316556980230",
      "public_metrics": {
        "retweet_count": 9,
        "reply_count": 3,
        "like_count": 26,
        "quote_count": 2
      },
      "author_id": "2244994945",
      "in_reply_to_user_id": "2244994945",
      "context_annotations": [
        {
          "domain": {
            "id": "46",
            "name": "品牌类别",
            "description": "品牌垂直领域内的类别,用于缩小品牌范围"
          },
          "entity": {
            "id": "781974596752842752",
            "name": "服务"
          }
        },
        {
          "domain": {
            "id": "47",
            "name": "品牌",
            "description": "品牌和公司"
          },
          "entity": {
            "id": "10045225402",
            "name": "Twitter"
          }
        },
        {
          "domain": {
            "id": "123",
            "name": "持续新闻事件",
            "description": "持续的新闻事件,如"英国脱欧""
          },
          "entity": {
            "id": "1220701888179359745",
            "name": "COVID-19"
          }
        }
      ],
      "source": "Twitter Web App",
      "created_at": "2020-08-21T19:10:05.000Z"
    }
  ],
  "includes": {
    "users": [
      {
        "created_at": "2013-12-14T04:35:55.000Z",
        "id": "2244994945",
        "protected": false,
        "username": "TwitterDev",
        "verified": true,
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.x.com/en/community",
                "display_url": "developer.x.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "description": "#TwitterDev 团队的官方声音,是您获取与 #TwitterAPI 相关的更新、新闻和活动的官方来源。",
        "pinned_tweet_id": "1293593516040269825",
        "public_metrics": {
          "followers_count": 513962,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "location": "127.0.0.1",
        "name": "Twitter 开发者",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1283786620521652229/lEODkLTh_normal.jpg",
        "url": "https://t.co/3ZX3TNiZCY"
      },
      {
        "created_at": "2013-07-23T16:58:03.000Z",
        "id": "1615654896",
        "protected": false,
        "username": "PennMedCDH",
        "verified": false,
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/7eS9RuwIb9",
                "expanded_url": "http://centerfordigitalhealth.upenn.edu/",
                "display_url": "centerfordigitalhealth.upenn.edu"
              }
            ]
          },
          "description": {
            "mentions": [
              {
                "start": 0,
                "end": 13,
                "username": "PennMedicine"
              }
            ]
          }
        },
        "description": "@PennMedicine 的数字健康中心通过研究数字健康技术在医疗保健领域进步的影响来推动科学发展。",
        "public_metrics": {
          "followers_count": 1348,
          "following_count": 455,
          "tweet_count": 1288,
          "listed_count": 92
        },
        "location": "Philadelphia, PA",
        "name": "宾大医学院 CDH",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1067488849725726723/MoO3FQ44_normal.jpg",
        "url": "https://t.co/7eS9RuwIb9"
      }
    ],
    "tweets": [
      {
        "lang": "en",
        "conversation_id": "1296887091901718529",
        "text": "@RainaMerchant 博士及其在宾夕法尼亚大学医学院 CDH 的团队正在帮助构建医疗保健的未来。\n\n该团队以多种不同方式使用社交数据洞察——从揭示风险因素到阐明公众情绪。🔎",
        "possibly_sensitive": false,
        "entities": {
          "annotations": [
            {
              "start": 39,
              "end": 55,
              "probability": 0.8274,
              "type": "Organization",
              "normalized_text": "Penn Medicine CDH"
            }
          ],
          "mentions": [
            {
              "start": 4,
              "end": 18,
              "username": "RainaMerchant"
            }
          ]
        },
        "id": "1296887091901718529",
        "public_metrics": {
          "retweet_count": 9,
          "reply_count": 7,
          "like_count": 32,
          "quote_count": 0
        },
        "author_id": "2244994945",
        "source": "Twitter Web App",
        "created_at": "2020-08-21T19:09:12.000Z"
      }
    ]
  }
}

扩展版 Tweet

{
  "data": [
    {
      "conversation_id": "1296121314218897408",
      "id": "1296121314218897408",
      "possibly_sensitive": false,
      "public_metrics": {
        "retweet_count": 54,
        "reply_count": 9,
        "like_count": 172,
        "quote_count": 23
      },
      "entities": {
        "urls": [
          {
            "start": 192,
            "end": 215,
            "url": "https://t.co/khXhTurm9x",
            "expanded_url": "https://devcommunity.x.com/t/hide-replies-now-available-in-the-new-twitter-api/140996",
            "display_url": "devcommunity.com/t/hide-replies…",
            "images": [
              {
                "url": "https://pbs.twimg.com/news_img/1296121315514957825/3CI24hSI?format=png&name=orig",
                "width": 400,
                "height": 400
              },
              {
                "url": "https://pbs.twimg.com/news_img/1296121315514957825/3CI24hSI?format=png&name=150x150",
                "width": 150,
                "height": 150
              }
            ],
            "status": 200,
            "title": "隐藏回复功能现已在新版 Twitter API 中推出",
            "description": "今天,我们很高兴地宣布新版 Twitter API 中隐藏回复端点正式上线。隐藏回复端点允许您构建工具,帮助用户隐藏或取消隐藏对其推文的回复。用户管理回复的原因有很多,包括减少对辱骂性、干扰性、误导性评论的关注,或使对话更具吸引力。通过此端点,您可以构建工具帮助 Twitter 用户更快、更便捷地隐藏或取消隐藏回复...",
            "unwound_url": "https://devcommunity.x.com/t/hide-replies-now-available-in-the-new-twitter-api/140996"
          }
        ],
        "hashtags": [
          {
            "start": 178,
            "end": 189,
            "tag": "TwitterAPI"
          }
        ]
      },
      "text": "隐藏回复端点今天正式发布!\n\n开发者可以隐藏对推文的回复 - 这是开发者使用 #TwitterAPI 帮助改善公共对话健康状况的关键方式。\n\nhttps://t.co/khXhTurm9x",
      "created_at": "2020-08-19T16:26:16.000Z",
      "context_annotations": [
        {
          "domain": {
            "id": "65",
            "name": "兴趣爱好垂直分类",
            "description": "顶级兴趣爱好分组,例如美食或旅行"
          },
          "entity": {
            "id": "848920371311001600",
            "name": "科技",
            "description": "科技与计算"
          }
        },
        {
          "domain": {
            "id": "66",
            "name": "兴趣爱好类别",
            "description": "兴趣爱好实体的分组,例如新奇美食或目的地"
          },
          "entity": {
            "id": "848921413196984320",
            "name": "计算机编程",
            "description": "计算机编程"
          }
        }
      ],
      "author_id": "2244994945",
      "lang": "en",
      "source": "Twitter 网页应用"
    }
  ],
  "includes": {
    "users": [
      {
        "created_at": "2013-12-14T04:35:55.000Z",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1283786620521652229/lEODkLTh_normal.jpg",
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.x.com/en/community",
                "display_url": "developer.x.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "id": "2244994945",
        "verified": true,
        "location": "127.0.0.1",
        "description": "#TwitterDev 团队的官方声音,是您获取与 #TwitterAPI 相关的更新、新闻和活动的官方来源。",
        "pinned_tweet_id": "1293593516040269825",
        "username": "TwitterDev",
        "public_metrics": {
          "followers_count": 513962,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "name": "Twitter 开发者",
        "url": "https://t.co/3ZX3TNiZCY",
        "protected": false
      }
    ]
  }
}

含媒体的 Tweet

{
  "data": [
    {
      "lang": "en",
      "conversation_id": "1293593516040269825",
      "text": "It’s finally here! 🥁 Say hello to the new #TwitterAPI.\n\nWe’re rebuilding the X API v2 from the ground up to better serve our developer community. And today’s launch is only the beginning.\n\nhttps://t.co/32VrwpGaJw https://t.co/KaFSbjWUA8",
      "attachments": {
        "media_keys": [
          "7_1293565706408038401"
        ]
      },
      "possibly_sensitive": false,
      "entities": {
        "annotations": [
          {
            "start": 78,
            "end": 88,
            "probability": 0.4381,
            "type": "Product",
            "normalized_text": "Twitter API"
          }
        ],
        "hashtags": [
          {
            "start": 42,
            "end": 53,
            "tag": "TwitterAPI"
          }
        ],
        "urls": [
          {
            "start": 195,
            "end": 218,
            "url": "https://t.co/32VrwpGaJw",
            "expanded_url": "https://blog.x.com/developer/en_us/topics/tools/2020/introducing_new_twitter_api.html",
            "display_url": "blog.x.com/developer/en_u…",
            "images": [
              {
                "url": "https://pbs.twimg.com/news_img/1336475659279818754/_cmRh7QE?format=jpg&name=orig",
                "width": 1200,
                "height": 627
              },
              {
                "url": "https://pbs.twimg.com/news_img/1336475659279818754/_cmRh7QE?format=jpg&name=150x150",
                "width": 150,
                "height": 150
              }
            ],
            "status": 200,
            "title": "Introducing a new and improved X API",
            "description": "Introducing the new X API - rebuilt from the ground up to deliver new features faster so developers can help the world connect to the public conversation happening on Twitter.",
            "unwound_url": "https://blog.x.com/developer/en_us/topics/tools/2020/introducing_new_twitter_api.html"
          },
          {
            "start": 219,
            "end": 242,
            "url": "https://t.co/KaFSbjWUA8",
            "expanded_url": "https://x.com/TwitterDev/status/1293593516040269825/video/1",
            "display_url": "pic.x.com/KaFSbjWUA8"
          }
        ]
      },
      "id": "1293593516040269825",
      "public_metrics": {
        "retweet_count": 958,
        "reply_count": 171,
        "like_count": 2848,
        "quote_count": 333
      },
      "author_id": "2244994945",
      "context_annotations": [
        {
          "domain": {
            "id": "46",
            "name": "Brand Category",
            "description": "Categories within Brand Verticals that narrow down the scope of Brands"
          },
          "entity": {
            "id": "781974596752842752",
            "name": "Services"
          }
        },
        {
          "domain": {
            "id": "47",
            "name": "Brand",
            "description": "Brands and Companies"
          },
          "entity": {
            "id": "10045225402",
            "name": "Twitter"
          }
        },
        {
          "domain": {
            "id": "65",
            "name": "Interests and Hobbies Vertical",
            "description": "Top level interests and hobbies groupings, like Food or Travel"
          },
          "entity": {
            "id": "848920371311001600",
            "name": "Technology",
            "description": "Technology and computing"
          }
        },
        {
          "domain": {
            "id": "66",
            "name": "Interests and Hobbies Category",
            "description": "A grouping of interests and hobbies entities, like Novelty Food or Destinations"
          },
          "entity": {
            "id": "848921413196984320",
            "name": "Computer programming",
            "description": "Computer programming"
          }
        }
      ],
      "source": "Twitter Web App",
      "created_at": "2020-08-12T17:01:42.000Z"
    }
  ],
  "includes": {
    "media": [
      {
        "height": 720,
        "duration_ms": 34875,
        "media_key": "7_1293565706408038401",
        "type": "video",
        "preview_image_url": "https://pbs.twimg.com/ext_tw_video_thumb/1293565706408038401/pu/img/66P2dvbU4a02jYbV.jpg",
        "public_metrics": {
          "view_count": 279438
        },
        "width": 1280
      }
    ],
    "users": [
      {
        "created_at": "2013-12-14T04:35:55.000Z",
        "id": "2244994945",
        "protected": false,
        "username": "TwitterDev",
        "verified": true,
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.x.com/en/community",
                "display_url": "developer.x.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "description": "The voice of the #TwitterDev team and your official source for updates, news, and events, related to the #TwitterAPI.",
        "pinned_tweet_id": "1293593516040269825",
        "public_metrics": {
          "followers_count": 513962,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "location": "127.0.0.1",
        "name": "Twitter Dev",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1283786620521652229/lEODkLTh_normal.jpg",
        "url": "https://t.co/3ZX3TNiZCY"
      }
    ]
  }
}`


### 转推

      `{
  "data": [
    {
      "public_metrics": {
        "retweet_count": 19,
        "reply_count": 0,
        "like_count": 0,
        "quote_count": 0
      },
      "conversation_id": "1229851574555508737",
      "id": "1229851574555508737",
      "entities": {
        "annotations": [
          {
            "start": 28,
            "end": 38,
            "probability": 0.261,
            "type": "Product",
            "normalized_text": "Alexa Skill"
          },
          {
            "start": 44,
            "end": 50,
            "probability": 0.7332,
            "type": "Product",
            "normalized_text": "Twitter"
          }
        ],
        "mentions": [
          {
            "start": 3,
            "end": 15,
            "username": "suhemparack"
          }
        ]
      },
      "text": "RT @suhemparack: I built an Alexa Skill for Twitter using APL that allows you to view Tweets and Trends on the echo show!\n\nCheck it out her…",
      "created_at": "2020-02-18T19:33:59.000Z",
      "possibly_sensitive": false,
      "author_id": "2244994945",
      "referenced_tweets": [
        {
          "type": "retweeted",
          "id": "1229843515603144704"
        }
      ],
      "context_annotations": [
        {
          "domain": {
            "id": "47",
            "name": "Brand",
            "description": "Brands and Companies"
          },
          "entity": {
            "id": "10026792024",
            "name": "Amazon"
          }
        },
        {
          "domain": {
            "id": "48",
            "name": "Product",
            "description": "Products created by Brands.  Examples: Ford Explorer, Apple iPhone."
          },
          "entity": {
            "id": "968221983803494400",
            "name": "Amazon - Alexa",
            "description": "Alexa"
          }
        },
        {
          "domain": {
            "id": "46",
            "name": "Brand Category",
            "description": "Categories within Brand Verticals that narrow down the scope of Brands"
          },
          "entity": {
            "id": "781974596752842752",
            "name": "Services"
          }
        },
        {
          "domain": {
            "id": "47",
            "name": "Brand",
            "description": "Brands and Companies"
          },
          "entity": {
            "id": "10045225402",
            "name": "Twitter"
          }
        }
      ],
      "source": "Twitter Web App",
      "lang": "en"
    }
  ],
  "includes": {
    "users": [
      {
        "profile_image_url": "https://pbs.twimg.com/profile_images/1283786620521652229/lEODkLTh_normal.jpg",
        "username": "TwitterDev",
        "name": "Twitter Dev",
        "location": "127.0.0.1",
        "url": "https://t.co/3ZX3TNiZCY",
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.x.com/en/community",
                "display_url": "developer.x.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "id": "2244994945",
        "description": "The voice of the #TwitterDev team and your official source for updates, news, and events, related to the #TwitterAPI.",
        "verified": true,
        "public_metrics": {
          "followers_count": 513962,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "pinned_tweet_id": "1293593516040269825",
        "created_at": "2013-12-14T04:35:55.000Z",
        "protected": false
      },
      {
        "profile_image_url": "https://pbs.twimg.com/profile_images/1230703695051935747/TbQKe91L_normal.jpg",
        "username": "suhemparack",
        "name": "Suhem Parack",
        "location": "Seattle, WA",
        "url": "https://t.co/8IkCzClPCz",
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/8IkCzClPCz",
                "expanded_url": "https://developer.x.com",
                "display_url": "developer.x.com"
              }
            ]
          },
          "description": {
            "mentions": [
              {
                "start": 42,
                "end": 50,
                "username": "Twitter"
              }
            ]
          }
        },
        "id": "857699969263964161",
        "description": "Developer Relations for Academic Research @Twitter. Talk to me about research with Twitter data. Previously: Amazon Alexa. Views are my own",
        "verified": false,
        "public_metrics": {
          "followers_count": 738,
          "following_count": 512,
          "tweet_count": 460,
          "listed_count": 12
        },
        "pinned_tweet_id": "1296498078233571329",
        "created_at": "2017-04-27T20:56:22.000Z",
        "protected": false
      }
    ],
    "tweets": [
      {
        "public_metrics": {
          "retweet_count": 19,
          "reply_count": 1,
          "like_count": 71,
          "quote_count": 6
        },
        "conversation_id": "1229843515603144704",
        "id": "1229843515603144704",
        "entities": {
          "annotations": [
            {
              "start": 11,
              "end": 21,
              "probability": 0.3342,
              "type": "Product",
              "normalized_text": "Alexa Skill"
            },
            {
              "start": 27,
              "end": 33,
              "probability": 0.6727,
              "type": "Product",
              "normalized_text": "Twitter"
            }
          ],
          "urls": [
            {
              "start": 127,
              "end": 150,
              "url": "https://t.co/l5J8wq748G",
              "expanded_url": "https://dev.to/twitterdev/building-an-alexa-skill-for-twitter-using-alexa-presentation-language-1aj0",
              "display_url": "dev.to/twitterdev/bui…",
              "status": 200,
              "unwound_url": "https://dev.to/twitterdev/building-an-alexa-skill-for-twitter-using-alexa-presentation-language-1aj0"
            }
          ]
        },
        "text": "I built an Alexa Skill for Twitter using APL that allows you to view Tweets and Trends on the echo show!\n\nCheck it out here 👇\n\nhttps://t.co/l5J8wq748G",
        "created_at": "2020-02-18T19:01:58.000Z",
        "possibly_sensitive": false,
        "author_id": "857699969263964161",
        "context_annotations": [
          {
            "domain": {
              "id": "47",
              "name": "Brand",
              "description": "Brands and Companies"
            },
            "entity": {
              "id": "10026792024",
              "name": "Amazon"
            }
          },
          {
            "domain": {
              "id": "48",
              "name": "Product",
              "description": "Products created by Brands.  Examples: Ford Explorer, Apple iPhone."
            },
            "entity": {
              "id": "968221983803494400",
              "name": "Amazon - Alexa",
              "description": "Alexa"
            }
          },
          {
            "domain": {
              "id": "46",
              "name": "Brand Category",
              "description": "Categories within Brand Verticals that narrow down the scope of Brands"
            },
            "entity": {
              "id": "781974596752842752",
              "name": "Services"
            }
          },
          {
            "domain": {
              "id": "47",
              "name": "Brand",
              "description": "Brands and Companies"
            },
            "entity": {
              "id": "10045225402",
              "name": "Twitter"
            }
          }
        ],
        "source": "Twitter Web App",
        "lang": "en"
      }
    ]
  }
}`


### 引用推文

      `{
  "data": [
    {
      "lang": "en",
      "conversation_id": "1328399838128467969",
      "text": "按计划,下方引用的 Labs v2 端点现已停用。如果您有任何疑问或需要 X API v2 方面的帮助,请在论坛中告知我们!https://t.co/JaxttUMmjX",
      "referenced_tweets": [
        {
          "type": "quoted",
          "id": "1327011423252144128"
        }
      ],
      "possibly_sensitive": false,
      "entities": {
        "annotations": [
          {
            "start": 151,
            "end": 157,
            "probability": 0.8115,
            "type": "Product",
            "normalized_text": "Twitter"
          }
        ],
        "urls": [
          {
            "start": 167,
            "end": 190,
            "url": "https://t.co/JaxttUMmjX",
            "expanded_url": "https://x.com/TwitterDev/status/1327011423252144128",
            "display_url": "twitter.com/TwitterDev/sta…"
          }
        ]
      },
      "id": "1328399838128467969",
      "public_metrics": {
        "retweet_count": 7,
        "reply_count": 4,
        "like_count": 29,
        "quote_count": 1
      },
      "author_id": "2244994945",
      "context_annotations": [
        {
          "domain": {
            "id": "46",
            "name": "Brand Category",
            "description": "品牌垂直领域内的类别,用于缩小品牌范围"
          },
          "entity": {
            "id": "781974596752842752",
            "name": "服务"
          }
        },
        {
          "domain": {
            "id": "47",
            "name": "Brand",
            "description": "品牌和公司"
          },
          "entity": {
            "id": "10045225402",
            "name": "Twitter"
          }
        },
        {
          "domain": {
            "id": "65",
            "name": "Interests and Hobbies Vertical",
            "description": "顶级兴趣和爱好分组,例如美食或旅行"
          },
          "entity": {
            "id": "848920371311001600",
            "name": "技术",
            "description": "技术和计算"
          }
        },
        {
          "domain": {
            "id": "66",
            "name": "Interests and Hobbies Category",
            "description": "兴趣和爱好实体的分组,例如新奇食品或目的地"
          },
          "entity": {
            "id": "848921413196984320",
            "name": "计算机编程",
            "description": "计算机编程"
          }
        }
      ],
      "source": "Twitter Web App",
      "created_at": "2020-11-16T18:09:36.000Z"
    }
  ],
  "includes": {
    "users": [
      {
        "created_at": "2013-12-14T04:35:55.000Z",
        "id": "2244994945",
        "protected": false,
        "username": "TwitterDev",
        "verified": true,
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.x.com/en/community",
                "display_url": "developer.x.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "description": "#TwitterDev 团队的声音,是您获取与 #TwitterAPI 相关的更新、新闻和活动的官方来源。",
        "pinned_tweet_id": "1293593516040269825",
        "public_metrics": {
          "followers_count": 513962,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "location": "127.0.0.1",
        "name": "Twitter Dev",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1283786620521652229/lEODkLTh_normal.jpg",
        "url": "https://t.co/3ZX3TNiZCY"
      }
    ],
    "tweets": [
      {
        "lang": "en",
        "conversation_id": "1327011423252144128",
        "text": "👋 友情提醒:Twitter Developer Labs v2 的隐藏回复和最近搜索功能将于下周一(11 月 16 日)停用!我们建议您迁移到 v2 #TwitterAPI 中现已提供的新隐藏回复和最近搜索端点。详情:https://t.co/r6z6CI7kEy",
        "possibly_sensitive": false,
        "entities": {
          "annotations": [
            {
              "start": 26,
              "end": 50,
              "probability": 0.4387,
              "type": "Product",
              "normalized_text": "Twitter Developer Labs v2"
            }
          ],
          "hashtags": [
            {
              "start": 228,
              "end": 239,
              "tag": "TwitterAPI"
            }
          ],
          "urls": [
            {
              "start": 250,
              "end": 273,
              "url": "https://t.co/r6z6CI7kEy",
              "expanded_url": "https://devcommunity.x.com/t/retiring-labs-v2-recent-search-and-hide-replies/145795",
              "display_url": "devcommunity.com/t/retiring-lab…",
              "images": [
                {
                  "url": "https://pbs.twimg.com/news_img/1327011425240313856/PkurOyu1?format=jpg&name=orig",
                  "width": 1200,
                  "height": 630
                },
                {
                  "url": "https://pbs.twimg.com/news_img/1327011425240313856/PkurOyu1?format=jpg&name=150x150",
                  "width": 150,
                  "height": 150
                }
              ],
              "status": 200,
              "title": "停用 Labs v2 最近搜索和隐藏回复",
              "description": "正如我们在早期访问和隐藏回复公告中所述,以下 Twitter Developer Labs v2 端点将于 11 月 16 日停用。Labs v2 最近搜索 Labs v2 隐藏回复 如果调用这些端点,它们将返回 HTTP 410 状态且不返回任何数据。根据您对 Labs 的反馈,我们已将相应功能整合到 X API v2 中。可通过以下链接查看相关文档。如果您尚未注册,请点击此处注册 v2 访问权限...",
              "unwound_url": "https://devcommunity.x.com/t/retiring-labs-v2-recent-search-and-hide-replies/145795"
            }
          ]
        },
        "id": "1327011423252144128",
        "public_metrics": {
          "retweet_count": 8,
          "reply_count": 2,
          "like_count": 33,
          "quote_count": 4
        },
        "author_id": "2244994945",
        "context_annotations": [
          {
            "domain": {
              "id": "46",
              "name": "Brand Category",
              "description": "品牌垂直领域内的类别,用于缩小品牌范围"
            },
            "entity": {
              "id": "781974596752842752",
              "name": "服务"
            }
          },
          {
            "domain": {
              "id": "47",
              "name": "Brand",
              "description": "品牌和公司"
            },
            "entity": {
              "id": "10045225402",
              "name": "Twitter"
            }
          },
          {
            "domain": {
              "id": "65",
              "name": "Interests and Hobbies Vertical",
              "description": "顶级兴趣和爱好分组,例如美食或旅行"
            },
            "entity": {
              "id": "848920371311001600",
              "name": "Technology",
              "description": "Technology and computing"
            }
          },
          {
            "domain": {
              "id": "66",
              "name": "Interests and Hobbies Category",
              "description": "兴趣和爱好实体的分组,例如新奇食品或目的地"
            },
            "entity": {
              "id": "848921413196984320",
              "name": "Computer programming",
              "description": "Computer programming"
            }
          }
        ],
        "source": "Twitter Web App",
        "created_at": "2020-11-12T22:12:32.000Z"
      }
    ]
  }
}

被转发的引用 Tweet

{
    "data": [
    {
      "lang": "en",
      "conversation_id": "1225470895902412800",
      "text": "RT @AureliaSpecker: 📣 If you enjoyed the London commute tutorial I wrote in November last year, check out the refactored version that uses…",
      "referenced_tweets": [
        {
          "type": "retweeted",
          "id": "1224709550214873090"
        }
      ],
      "possibly_sensitive": false,
      "entities": {
        "annotations": [
          {
            "start": 42,
            "end": 47,
            "probability": 0.6999,
            "type": "Place",
            "normalized_text": "London"
          }
        ],
        "mentions": [
          {
            "start": 3,
            "end": 18,
            "username": "AureliaSpecker"
          }
        ]
      },
      "id": "1225470895902412800",
      "public_metrics": {
        "retweet_count": 12,
        "reply_count": 0,
        "like_count": 0,
        "quote_count": 0
      },
      "author_id": "2244994945",
      "context_annotations": [
        {
          "domain": {
            "id": "46",
            "name": "品牌类别",
            "description": "品牌垂直领域内用于细化品牌范围的类别"
          },
          "entity": {
            "id": "781974596752842752",
            "name": "服务"
          }
        },
        {
          "domain": {
            "id": "47",
            "name": "品牌",
            "description": "品牌与公司"
          },
          "entity": {
            "id": "10045225402",
            "name": "Twitter"
          }
        },
        {
          "domain": {
            "id": "65",
            "name": "兴趣爱好垂直领域",
            "description": "顶级兴趣爱好分组,如美食或旅行"
          },
          "entity": {
            "id": "848920371311001600",
            "name": "科技",
            "description": "科技与计算"
          }
        },
        {
          "domain": {
            "id": "66",
            "name": "兴趣爱好类别",
            "description": "兴趣爱好实体的分组,如新奇美食或旅行目的地"
          },
          "entity": {
            "id": "848921413196984320",
            "name": "计算机编程",
            "description": "计算机编程"
          }
        }
      ],
      "source": "Twitter for iPhone",
      "created_at": "2020-02-06T17:26:44.000Z"
    }
  ],
  "includes": {
    "users": [
      {
        "created_at": "2013-12-14T04:35:55.000Z",
        "id": "2244994945",
        "protected": false,
        "username": "TwitterDev",
        "verified": true,
        "entities": {
          "url": {
            "urls": [
              {
                "start": 0,
                "end": 23,
                "url": "https://t.co/3ZX3TNiZCY",
                "expanded_url": "https://developer.x.com/en/community",
                "display_url": "developer.x.com/en/community"
              }
            ]
          },
          "description": {
            "hashtags": [
              {
                "start": 17,
                "end": 28,
                "tag": "TwitterDev"
              },
              {
                "start": 105,
                "end": 116,
                "tag": "TwitterAPI"
              }
            ]
          }
        },
        "description": "#TwitterDev 团队的官方声音,您获取 #TwitterAPI 相关更新、资讯和活动的官方来源。",
        "pinned_tweet_id": "1293593516040269825",
        "public_metrics": {
          "followers_count": 513962,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "location": "127.0.0.1",
        "name": "Twitter Dev",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1283786620521652229/lEODkLTh_normal.jpg",
        "url": "https://t.co/3ZX3TNiZCY"
      },
      {
        "created_at": "2013-01-18T23:45:43.000Z",
        "id": "1102321381",
        "protected": false,
        "username": "AureliaSpecker",
        "verified": false,
        "entities": {
          "description": {
            "mentions": [
              {
                "start": 7,
                "end": 17,
                "username": "TwitterUK"
              },
              {
                "start": 86,
                "end": 95,
                "username": "_dormrod"
              }
            ]
          }
        },
        "description": "@TwitterUK 开发者关系 • 伦敦的瑞士人 • 室内植物爱好者 • @_dormrod 的专属理发师",
        "pinned_tweet_id": "1253069421322567681",
        "public_metrics": {
          "followers_count": 1036,
          "following_count": 1330,
          "tweet_count": 855,
          "listed_count": 26
        },
        "location": "英国伦敦",
        "name": "Aurelia Specker",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1137517534104772608/8FBYgc6G_normal.jpg",
        "url": ""
      }
    ],
    "tweets": [
      {
        "lang": "en",
        "conversation_id": "1224709550214873090",
        "text": "📣 If you enjoyed the London commute tutorial I wrote in November last year, check out the refactored version that uses Twitter's new search endpoint 🚇 https://t.co/87XIPZmZBJ\n\n#DEVcommunity #Pythontutorial @TwitterDev @TwitterAPI https://t.co/dXrJYvn3hY",
        "referenced_tweets": [
          {
            "type": "quoted",
            "id": "1195000047089389573"
          }
        ],
        "possibly_sensitive": false,
        "entities": {
          "annotations": [
            {
              "start": 22,
              "end": 27,
              "probability": 0.7075,
              "type": "Place",
              "normalized_text": "London"
            },
            {
              "start": 120,
              "end": 126,
              "probability": 0.7355,
              "type": "Product",
              "normalized_text": "Twitter"
            }
          ],
          "mentions": [
            {
              "start": 206,
              "end": 217,
              "username": "TwitterDev"
            },
            {
              "start": 218,
              "end": 229,
              "username": "TwitterAPI"
            }
          ],
          "hashtags": [
            {
              "start": 176,
              "end": 189,
              "tag": "DEVcommunity"
            },
            {
              "start": 190,
              "end": 205,
              "tag": "Pythontutorial"
            }
          ],
          "urls": [
            {
              "start": 151,
              "end": 174,
              "url": "https://t.co/87XIPZmZBJ",
              "expanded_url": "https://bit.ly/2OrnrCC",
              "display_url": "bit.ly/2OrnrCC",
              "status": 200,
              "unwound_url": "https://dev.to/twitterdev/migrate-to-twitter-s-newly-released-labs-recent-search-endpoint-3npe"
            },
            {
              "start": 230,
              "end": 253,
              "url": "https://t.co/dXrJYvn3hY",
              "expanded_url": "https://x.com/AureliaSpecker/status/1195000047089389573",
              "display_url": "twitter.com/AureliaSpecker…"
            }
          ]
        },
        "id": "1224709550214873090",
        "public_metrics": {
          "retweet_count": 12,
          "reply_count": 0,
          "like_count": 43,
          "quote_count": 2
        },
        "author_id": "1102321381",
        "context_annotations": [
          {
            "domain": {
              "id": "46",
              "name": "品牌类别",
              "description": "品牌垂直领域内用于细化品牌范围的类别"
            },
            "entity": {
              "id": "781974596752842752",
              "name": "服务"
            }
          },
          {
            "domain": {
              "id": "47",
              "name": "品牌",
              "description": "品牌与公司"
            },
            "entity": {
              "id": "10045225402",
              "name": "Twitter"
            }
          },
          {
            "domain": {
              "id": "65",
              "name": "兴趣爱好垂直分类",
              "description": "顶级兴趣爱好分组,例如美食或旅行"
            },
            "entity": {
              "id": "848920371311001600",
              "name": "科技",
              "description": "科技与计算机"
            }
          },
          {
            "domain": {
              "id": "66",
              "name": "兴趣爱好类别",
              "description": "兴趣爱好实体分组,例如新奇美食或旅行目的地"
            },
            "entity": {
              "id": "848921413196984320",
              "name": "计算机编程",
              "description": "计算机编程"
            }
          }
        ],
        "source": "X 网页应用",
        "created_at": "2020-02-04T15:01:25.000Z"
      }
    ]
  }
}