跳转到主要内容

对象模型

Tweet

Tweet 是 X 上所有内容的基本构建单元。Tweet 对象包含一长串“根级”字段(fields),例如 idtextcreated_at。Tweet 对象还是多个子对象的“父”对象,包括 usermediapollplace。在请求 Tweet 对象的这些根级字段时,请使用参数 tweet.fields 可以在 user 资源中找到并展开(expand)Tweet 对象。与所请求 Tweet 相关的其他 tweets 也可在 Tweet 资源中找到并展开。该对象可在 user 资源中通过 ?expansions=pinned_tweet_id,或在 Tweet 资源中通过 ?expansions=referenced_tweets.id 进行展开,以仅获取带有默认字段的对象。在请求额外字段以完善该对象时,请将 expansions 与参数 tweet.fields 搭配使用。
字段值类型描述使用方式
id (默认)string请求的 Tweet 的唯一标识符。使用此标识符以编程方式检索特定的 Tweet。
text (默认)stringTweet 的实际 UTF-8 文本。有关有效字符的详细信息,请参阅 twitter-text关键词提取和情感分析/分类。
edit_history_tweet_ids (默认)object表示 Tweet 所有版本的唯一标识符。对于未编辑的 Tweet,将有一个 ID。对于有编辑历史的 Tweet,将有多个 ID。使用此信息查找 Tweet 的编辑历史。
articleobject包含此 Tweet 中存在的文章的元数据。使用此字段获取文章的文本和实体。
attachmentsobject指定此 Tweet 中存在的附件类型(如果有)。了解为请求的扩展返回的对象。
author_idstring发布此 Tweet 的用户的唯一标识符。填充用户对象,共享数据集以供同行评审。
card_uristring此 Tweet 中存在的卡片的 URI。
community_idstring此 Post 所属社区的唯一标识符。
context_annotationsarray包含 Tweet 的上下文注释。实体识别/提取,主题分析。
conversation_idstring对话的原始 Tweet 的 Tweet ID(包括直接回复、回复的回复)。使用此字段从 Tweet 重构对话。
created_atdate (ISO 8601)Tweet 的创建时间。对时间序列分析和了解 Tweet 创建时间很有用。
display_text_rangearray包含显示文本部分的开始和结束索引的数组。对于了解长帖子默认显示的文本部分很有用。
edit_controlsobject指示 Tweet 还能编辑多长时间以及剩余编辑次数。使用此字段确定 Tweet 是否符合编辑条件。
entitiesobject从 Tweet 文本中解析出的实体。请参阅 Twitter 对象中的实体。提供有关话题标签、URL、提及等的附加信息。
geoobject指示地理标记 Tweet 的位置或地点。使用此字段获取地理标记 Tweet 的位置。
in_reply_to_user_idstring如果所表示的 Tweet 是回复,此字段将包含原始 Tweet 的作者 ID。确定 Tweet 是否是对另一个 Tweet 的回复。
langstringTweet 的语言,如果被 Twitter 检测到。按口语对 Tweet 进行分类。
non_public_metricsobject请求时 Tweet 的非公开参与度量。需要用户上下文身份验证。确定为 Tweet 生成的总展示次数。
note_tweetobject包含长篇 Post(>280 个字符)的完整文本。获取帖子的完整文本。
organic_metricsobject请求时在自然上下文中跟踪的 Tweet 参与度量。需要用户上下文身份验证。衡量 Tweet 的自然参与度。
possibly_sensitiveboolean指示内容是否可能被识别为敏感内容。研究某些类型内容的传播。
promoted_metricsobject请求时在推广上下文中跟踪的 Tweet 参与度量。需要用户上下文身份验证。衡量 Tweet 被推广时的参与度。
public_metricsobject请求时 Tweet 的公开参与度量。衡量 Tweet 参与度。
referenced_tweetsarray此 Tweet 引用的 Tweet 列表,例如转发、引用 Tweet 或回复。了解转发等的对话方面。
reply_settingsstring显示谁可以回复给定的 Tweet。选项有 “everyone”、“mentioned_users” 和 “followers”。确定 Tweet 的对话回复设置。
withheldobject包含被扣留内容的扣留详细信息。
scopesobject包含 Tweet 的范围详细信息。指示谁可以查看帖子。仅对推广帖子返回。
media_metadataarray包含 Tweet 媒体附件的元数据。获取附加元数据,如 Tweet 媒体附件的 alt_text
检索 Tweet 对象 示例请求 在以下请求中,我们在 Tweets lookup endpoint 上请求该 Tweet 的 fields。请务必将 $BEARER_TOKEN 替换为你自行生成的 OAuth 2.0 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
      }
    ]
  }

用户

用户对象包含用于描述所引用用户的 Twitter 账户元数据。用户对象是在 users lookup endpoint 中返回的主要对象。在该 endpoint 请求额外的用户字段时,只需使用 user.fields 参数。 用户对象也可以作为子对象出现,并在 Tweet 对象中进行展开。可通过 ?expansions=author_id?expansions=in_reply_to_user_id 进行展开,以获取仅包含默认字段的精简对象。若需补充完整该对象,请在使用 expansion 的同时配合字段参数 user.fields 请求额外字段。  
字段值类型描述使用方式
id (default)string该用户的唯一标识符。

"id": "2244994945"
用于以编程方式检索特定 Twitter 用户的信息。
name (default)string用户的显示名称,由用户在其个人资料中定义。不一定是真实姓名。通常限制在 50 个字符以内,但可能会发生变化。

"name": "Twitter Dev"
username (default)string该用户的 Twitter 用户名、昵称或别名。用户名是唯一的,但可能会发生变化。通常最多 15 个字符长,但某些历史账户可能存在更长的名称。

"username": "TwitterDev"
affiliationobject包含用户关联信息的详细信息。可用于获取用户的关联徽章。
confirmed_emailstring已认证用户的确认邮箱地址。
connection_statusarray提供认证用户与被查询用户之间的关系列表,如关注、被关注、发送关注请求、收到关注请求、屏蔽、静音

”connection_status”: [
“follow_request_received”,
“follow_request_sent”,
“blocking”,
“followed_by”,
“following”,
“muting”
]
可用于确定认证用户与被查询用户之间的连接状态。
created_atdate (ISO 8601)用户账户在 Twitter 上创建的 UTC 日期时间。

"created_at": "2013-12-14T04:35:55.000Z"
可用于确定某人使用 Twitter 的时长
descriptionstring该用户个人资料描述(也称为简介)的文本,如果用户提供了的话。

"description": "The voice of the X Dev team and your official source for updates, news, and events, related to the X API."
entitiesobject包含用户描述中具有特殊含义的文本的详细信息。

"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/> }
实体是 JSON 对象,提供与描述相关的话题标签、URL、用户提及和股票代码的附加信息。请参考各自的实体以获取更多详细信息。

所有用户 start 索引都是包含的,而所有用户 end 索引都是排除的。
is_identity_verifiedboolean指示用户是否已通过身份验证。
locationstring用户在个人资料中指定的位置,如果用户提供了的话。由于这是一个自由格式的值,它可能不表示有效位置,但在执行位置查询搜索时可能会进行模糊匹配。

"location": "127.0.0.1"
most_recent_tweet_idstring该用户最新 Tweet 的唯一标识符。确定用户的最新 Tweet。
parodyboolean指示该用户账户是否具有恶搞标签。
pinned_tweet_idstring该用户置顶 Tweet 的唯一标识符。

"pinned_tweet_id": "1255542774432063488"
确定置顶到用户个人资料顶部的 Tweet。可能用于确定用户的语言。
profile_banner_urlstring该用户个人资料横幅的 URL,如用户个人资料中显示的那样。

"profile_banner_url": "https://pbs.twimg.com/profile_banners/1716450569358098432/1721022977"
可用于下载该用户的个人资料横幅。
profile_image_urlstring该用户个人资料图像的 URL,如用户个人资料中显示的那样。

"profile_image_url": "https://pbs.twimg.com/profile_images/1267175364003901441/tBZNFAgA_normal.jpg"
可用于下载该用户的个人资料图像。
protectedboolean指示该用户是否选择保护他们的 Tweets(换句话说,该用户的 Tweets 是否为私密)。

"protected": false
public_metricsobject包含此用户的活动详情。

"public_metrics": { "followers_count": 507902, "following_count": 1863, "tweet_count": 3561, "listed_count": 1550 }
可用于确定 X 用户的影响范围或影响力,量化用户的兴趣范围,以及用户在 X 上的参与度。
receives_your_dmboolean指示此用户是否会接收已认证用户的私信。
subscriptionobject包含用户是否订阅已认证用户的详情。
subscription_typestring表示已认证用户拥有的 X Premium 订阅类型的字符串。示例:NoneBasicPremiumPremiumPlus。如果用户不是已认证用户,将始终返回 None
urlstring用户个人资料中指定的 URL(如果存在)。

"url": "https://t.co/3ZX3TNiZCY"
X 用户在其个人资料中提供的 URL。这可能是主页,但并非总是如此。
verifiedboolean指示此用户是否为已验证的 X 用户。

"verified": true
指示此 X 用户是否拥有已验证账户。已验证账户让人们知道公众关注的账户是真实的。
verified_followers_countstring表示用户已验证关注者数量的字符串。
verified_typestring表示用户拥有的验证类型的字符串。示例:“blue”、“business”、“government”
withheldobject包含被屏蔽内容的屏蔽详情(如适用)。
检索用户对象 示例请求 在下面的请求中,我们通过 users lookup endpoint 为该用户请求指定的 fields。请务必将 $BEARER_TOKEN 替换为你自行生成的 OAuth 2.0 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": "Twitter Dev",
            "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": "Twitter #DevRel 团队的声音,您获取 Twitter 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": "在这个前所未有的时期,Twitter 上发生的事情可以帮助世界更好地理解和应对疫情。\n\n我们正在推出免费的 COVID-19 stream endpoint,让符合条件的开发者和研究人员能够实时研究公共对话。https://t.co/BPqMcQzhId"
            }
        ]
    }
}

Space

Spaces 通过实时音频对话实现表达与互动。Space 数据字典包含与 Space 相关的 metadata;所有细节都会实时更新。 用户对象可在 user 资源中查找并通过扩展获取。通过在 expansions query 参数中添加至少一个 host_idscreator_idspeaker_idsmentioned_user_ids,即可返回这些对象的扩展信息。 与 Tweets 不同,Spaces 具有时效性,在结束后或被创建者取消时将不可用。当你的 App 处理 Spaces 数据时,你有责任返回最新信息,并且必须移除平台上已不再可用的数据。Spaces lookup endpoints 可帮助你确保尊重用户的期望与意图。
字段值类型描述使用方式
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"]
扩展用户对象,了解参与度。
langstring如检测到,Space 的语言。
"lang": "en"
按语言对 Spaces 进行分类。
is_ticketedboolean指示该 Space 是否为售票 Space。
"is_ticketed": false
突出重点内容。
invited_user_idsarray受邀担任发言者的用户 ID 列表。
"invited_user_ids": ["2244994945", "6253282"]
扩展用户对象,了解参与度。
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"]
扩展用户对象,了解参与度。
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"]
识别关键词、话题标签和提及。
updated_atdate (ISO 8601)Space metadata 的最后一次更新。
"updated_at": "2021-07-11T14:44:44.000Z"
保持信息最新。
检索 Space 对象 示例请求 在以下请求中,我们通过 Spaces lookup endpoint 为该 Space 指定返回的 fields。请务必将 $BEARER_TOKEN 替换为你自行生成的 OAuth 2.0 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 data 对象问好!",
    "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 对象包含用于描述所引用 List 的 Twitter Lists metadata。List 对象是 List 查询 endpoint 返回的主要对象。在该 endpoint 请求额外的 List 字段时,只需使用 fields 参数 list.fields List 对象不会作为其他数据对象的子对象出现。不过,可以在用户资源中查找并展开用户对象。通过在 expansions query 参数中添加 owner_id,即可展开这些对象。当需要请求附加字段以完善主要的 List 对象时,将此展开与 list.fields 字段参数一起使用;并使用 user.fields 来完善展开对象。
Field ValueTypeDescriptionHow it can be used
id (default)string此 List 的唯一标识符。
"id": "2244994945"
用于以编程方式检索特定 List 的信息。
name (default)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"
可用于判断该用户是否拥有其他 Lists,并展开用户对象。
检索用户对象 示例请求 在以下请求中,我们在 List lookup by ID endpoint 上请求该 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 对象不是任何 endpoint 的主对象,但可以在 Tweet 对象中找到并通过 expansions 获取。通过 ?expansions=attachments.media_keys 可展开并获取仅包含默认字段的精简对象。若需补全对象中的更多字段,请在使用该 expansions 的同时指定字段参数:media.fields
字段值类型说明用途
media_key(默认)string已展开媒体内容的唯一标识符。
"media_key": "13_1263145212760805376"
可用于以编程方式检索媒体
type(默认)string内容类型(animated_gif、photo、video)。
"type": "video"
将媒体归类为照片、GIF 或视频
urlstring指向 X 上媒体文件的直接 URL。对于照片,返回带有 URL 字段的 Media 对象
duration_msinteger当 type 为 video 时可用。视频的时长(毫秒)。
"duration_ms": 46947
heightinteger此内容的高度(像素)。
"height": 1080
non_public_metricsobject请求时刻媒体内容的非公开互动度量。需要用户 context 认证。
"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)下跟踪的媒体内容互动度量。需要用户 context 认证。
"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)下跟踪的媒体内容互动度量。需要用户 context 认证。
"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 文本。
"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 endpoint 上请求该 Tweet 所附带的 media 对象的 fields。由于 media 是 Tweet 的子对象,因此必须包含 attachment.media_keys 扩展。请务必将 $BEARER_TOKEN 替换为你自行生成的 OAuth 2.0 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 中的投票并不是任何 endpoint 的主对象,但可在 Tweet 对象中找到并通过扩展获取。可使用 ?expansions=attachments.poll_ids 扩展以返回仅含默认字段的精简对象。若需请求更多字段以补全该对象,请在扩展的同时使用字段参数 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 endpoint 上请求附加于该 Tweet 的投票对象字段。由于投票是 Tweet 的子对象,必须使用 attachments.poll_id 扩展。请务必将 $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"
      }
    ]
  }
}

地点

在任何 endpoint 上,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 endpoint 上请求附加到该 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": "曼哈顿,纽约"
      }
    ]
  }
}

私信事件

私信(DM)会话由一系列事件组成。X API v2 目前支持三种事件类型:MessageCreate、ParticipantsJoin 和 ParticipantsLeave。 DM 事件对象由 Direct Message lookup endpoint 返回;当通过 Manage Direct Messages endpoint 成功创建私信时,会生成一个 MessageCreate 事件。 在请求 DM 事件时,默认包含三个事件对象属性(或 fields):id、event_type 和 text。若要获取更多事件 fields,请使用 fields 参数 dm_event.fields 选择其他字段。其他可用的事件 fields 包括:dm_conversation_id、created_at、sender_id、attachments、participant_ids 和 referenced_tweets。 以下多个字段提供了与该私信事件相关的其他 X 对象的 ID:
  • sender_id - 发送消息的账号 ID,或将参与者邀请加入群组会话的账号 ID
  • participant_ids - 账号 ID 的数组。对于 ParticipantsJoin 和 ParticipantsLeave 事件,此数组将仅包含创建该事件的账号的一个 ID
  • attachments - 提供发送方上传至 X 的内容所对应的媒体 ID
  • referenced_tweets - 如果在 text 字段中检测到 Tweet URL,响应中将包含该 Tweet 的 ID
可使用 sender_id、participant_ids、referenced_tweets.id 和 attachments.media_keys 的 expansions 来展开这些 X 对象 ID。
字段值类型说明用途
id (default)string事件的唯一标识符。

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

* MessageCreate

* ParticipantsJoin

* ParticipantsLeave


”event_type”: “MessageCreate”
在检索会话历史时用于判断消息创建时间;对于群组会话,用于了解参与者的加入与离开。所有 GET 方法均支持使用 event_type= 查询参数过滤特定事件类型。
text (default)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”

    ]

用于了解附加到私信的媒体对象。
检索私信事件对象 示例请求 在此示例中,我们将构建一个请求,以检索与一对一会话相关的事件。该请求将返回基础的私信事件字段,以及被引用的 Tweets 及其作者的附加字段。我们来构建一个 query,请求以下内容:
  • 基础事件属性,例如其创建时间及其所属的会话(dm_conversation)。
  • 发送私信者的账号 ID 和描述。
  • 任何被引用 Tweet 的文本及其发布时间。
  • 任何被引用 Tweet 作者的账号 ID 和描述。
要返回这些属性,你的请求 query 将包含以下内容: ?dm_event.fields=id,sender_id,text,created_at,dm_conversation_id&expansions=sender_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 替换为你自己生成的 OAuth 2.0 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 演示",
				"description": "托管 TwitterDev 集成... @TwitterDev #DevRel",
				"id": "944480690",
				"username": "FloodSocial"
			},
			{
				"name": "雪地机器人",
				"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 用户进行交流、分享,并与其最关心的讨论更紧密连接的专属空间。 社区中的 Post 在 X 上对任何人可见,但只有该社区内的成员才能参与互动与讨论。 Community 对象包含与某个社区相关的 metadata。
字段值类型描述
created_at日期(ISO 8601)社区的创建时间。
id字符串社区的唯一标识符。
name字符串社区的名称。
description字符串社区描述的文本(如有)。
access字符串社区的访问级别。

可能的取值:
- Public
- Closed
join_policy字符串社区的加入策略。

可能的取值:
- Open
- RestrictedJoinRequestsDisabled
- RestrictedJoinRequestsRequireAdminApproval
- RestrictedJoinRequestsRequireModeratorApproval
- SuperFollowRequired
member_count整数已加入该社区的成员数量。
检索 Community 对象 示例请求 在以下请求中,我们在基于给定关键词搜索社区列表的同时请求了特定 fields。请务必将 $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": "Open",
      "access": "Public",
      "member_count": 39915,
      "name": "动漫社区",
      "created_at": "2024-02-17T06:58:50.000Z"
    },
    {
      "id": "Q29tbXVuaXR5OjE1MDY3OTM5NTMxMDYwNDI4OTE=",
      "description": "加入我们,一起聊动漫 🥰",
      "join_policy": "Open",
      "access": "Public",
      "member_count": 26019,
      "name": "动漫世界 🌸",
      "created_at": "2022-03-24T00:44:07.000Z"
    },
    {
      "id": "Q29tbXVuaXR5OjE0OTY3NzYyMTU5Mzk1MzQ4NDk=",
      "description": "专为动漫爱好者和创作者打造!",
      "join_policy": "Open",
      "access": "Public",
      "member_count": 5612,
      "name": "动漫",
      "created_at": "2022-02-24T09:17:13.000Z"
    }
  ],
  "meta": {
    "next_token": "7140dibdnow9c7btw481s8m561gat797rboud5r80xvzm"
  }
}

如何使用 fields 和 expansions

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

请求额外的 fields 和对象

首先,我们将使用 Tweet ID 和 GET /tweets endpoint 来请求一个 Tweet 对象 请求:
curl --request GET --url 'https://api.x.com/2/tweets?ids=1260294888811347969' \
  --header 'Authorization: Bearer $BEARER_TOKEN'
响应:
{
    "data": [
        {
            "id": "1260294888811347969",
            "text": "不要错过关于您的 Tweet 的 Tweets。\n\n现在在 iOS 上,您可以在一个地方查看所有带评论的转发。https://t.co/oanjZfzC6y"
        }
    ]
}
以下分步指南将向您展示如何获取我们在屏幕截图中看到的附加数据。
  1. 通过我们的object model,或查看各 endpoint 的 API 参考页面中的 fields 列表,确定你希望请求的其他 fields。 在这种情况下,我们将请求以下附加 fields: attachments、author_id、created_at、public_metrics。
  2. 使用逗号分隔的列表,将上述字段作为其值来构建 tweet.fields query(查询)参数: ?tweet.fields=attachments,author_id,created_at,public_metrics
  3. 将 query 参数添加到你之前发起的 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' 响应:
{
    "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 中包含的视频相关的 fields。为此,我们将使用 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 的 Tweets。\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 的 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
            },
            "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  
将这些参数合并后,完整的 query 字符串如下:
?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 endpoint 时会看到的内容。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 地图,其中包含展示情绪、报告症状、按州数据切分以及边境相关数据的图表。此外,他们的“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 网页版 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 Dev",
        "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": "美国宾夕法尼亚州费城",
        "name": "Penn Med 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 医生和她在宾大医学数字健康中心(Penn Medicine 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 网页版 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 中隐藏回复 endpoint 的正式上线。隐藏回复 endpoint 允许您构建工具,帮助用户隐藏或显示其 Tweet 的回复。用户管理回复的原因很多,包括减少对恶意、干扰性、误导性评论的关注,或让对话更有吸引力。通过此 endpoint,您可以构建工具,帮助 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": "隐藏回复 endpoint 今天正式上线!\n\n开发者可以隐藏 Tweet 的回复 - 这是开发者使用 #TwitterAPI 帮助改善公共对话健康度的重要方式。\n\nhttps://t.co/khXhTurm9x",
      "created_at": "2020-08-19T16:26:16.000Z",
      "context_annotations": [
        {
          "domain": {
            "id": "65",
            "name": "Interests and Hobbies Vertical",
            "description": "顶级兴趣和爱好分类,如美食或旅行"
          },
          "entity": {
            "id": "848920371311001600",
            "name": "Technology",
            "description": "技术与计算"
          }
        },
        {
          "domain": {
            "id": "66",
            "name": "Interests and Hobbies Category",
            "description": "兴趣和爱好实体分组,如特色美食或旅游目的地"
          },
          "entity": {
            "id": "848921413196984320",
            "name": "Computer programming",
            "description": "计算机编程"
          }
        }
      ],
      "author_id": "2244994945",
      "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": 513962,
          "following_count": 2039,
          "tweet_count": 3635,
          "listed_count": 1672
        },
        "name": "Twitter Dev",
        "url": "https://t.co/3ZX3TNiZCY",
        "protected": false
      }
    ]
  }
}

含媒体的 Tweet

{
  "data": [
    {
      "lang": "en",
      "conversation_id": "1293593516040269825",
      "text": "终于来了!🥁 向全新的 #TwitterAPI 问好。\n\n我们正在从头开始重建 X API v2,以更好地服务我们的开发者社区。今天的发布仅仅是个开始。\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": "介绍全新升级的 X API",
            "description": "介绍全新的 X API - 从头开始重建,以更快地提供新功能,让开发者能够帮助世界连接到 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": "品牌类别",
            "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 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": "#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"
      }
    ]
  }
}


### 转发

      `{
  "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 技能"
          },
          {
            "start": 44,
            "end": 50,
            "probability": 0.7332,
            "type": "Product",
            "normalized_text": "Twitter"
          }
        ],
        "mentions": [
          {
            "start": 3,
            "end": 15,
            "username": "suhemparack"
          }
        ]
      },
      "text": "转发 @suhemparack:我开发了一个适用于 Twitter 的 Alexa 技能,使用 APL,可在 Echo Show 上查看 Tweets 和趋势!\n\n来看看……",
      "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": "品牌",
            "description": "品牌和公司"
          },
          "entity": {
            "id": "10026792024",
            "name": "Amazon"
          }
        },
        {
          "domain": {
            "id": "48",
            "name": "产品",
            "description": "由品牌创建的产品。例如:Ford Explorer、Apple iPhone。"
          },
          "entity": {
            "id": "968221983803494400",
            "name": "Amazon - Alexa",
            "description": "Alexa"
          }
        },
        {
          "domain": {
            "id": "46",
            "name": "品牌类别",
            "description": "品牌纵向中的类别,用于缩小品牌范围"
          },
          "entity": {
            "id": "781974596752842752",
            "name": "服务"
          }
        },
        {
          "domain": {
            "id": "47",
            "name": "Brand",
            "name": "品牌",
            "description": "品牌和公司"
          "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": "#TwitterDev 团队的声音,你获取与 #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": "负责学术研究的开发者关系 @Twitter。欢迎与我交流使用 Twitter data 开展研究。此前:Amazon Alexa。观点仅代表个人。",
        "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 技能"
            },
            {
              "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": "我开发了一个适用于 Twitter 的 Alexa 技能,使用 APL,可在 Echo Show 上查看 Tweets 和趋势!\n\n来这里看看 👇\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": "品牌",
              "description": "品牌和公司"
            },
            "entity": {
              "id": "10026792024",
              "name": "Amazon"
            }
          },
          {
            "domain": {
              "id": "48",
              "name": "产品",
              "description": "由品牌创建的产品。例如:Ford Explorer、Apple iPhone。"
            },
            "entity": {
              "id": "968221983803494400",
              "name": "Amazon - Alexa",
              "description": "Alexa"
            }
          },
          {
            "domain": {
              "id": "46",
              "name": "品牌类别",
              "description": "品牌纵向中的类别,用于缩小品牌范围"
            },
            "entity": {
              "id": "781974596752842752",
              "name": "服务"
            }
          },
          {
            "domain": {
              "id": "47",
              "name": "品牌",
              "description": "品牌和公司"
            },
            "entity": {
              "id": "10045225402",
              "name": "Twitter"
            }
          }
        ],
        "source": "Twitter Web App",
        "lang": "en"
      }
    ]
  }
}`


### 引用 Tweet

      `{
  "data": [
    {
      "lang": "en",
      "conversation_id": "1328399838128467969",
      "text": "按计划,下面引用的 Labs v2 endpoint 现已停用。如果您对 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": "Technology",
            "description": "技术和计算"
          }
        },
        {
          "domain": {
            "id": "66",
            "name": "Interests and Hobbies Category",
            "description": "兴趣和爱好实体的分组,如新奇食品或目的地"
          },
          "entity": {
            "id": "848921413196984320",
            "name": "Computer programming",
            "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 中新提供的隐藏回复和最近搜索 endpoint。详情: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 endpoint 将于11月16日停用。Labs v2 最近搜索 Labs v2 隐藏回复 如果调用这些 endpoint,它们将响应 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": "技术和计算"
            }
          },
          {
            "domain": {
              "id": "66",
              "name": "Interests and Hobbies Category",
              "description": "兴趣和爱好实体的分组,如新奇食品或目的地"
            },
            "entity": {
              "id": "848921413196984320",
              "name": "Computer programming",
              "description": "计算机编程"
            }
          }
        ],
        "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": "devrel @TwitterUK • 在伦敦的瑞士人 • 室内植物之母 • @_dormrod 的私人理发师",
        "pinned_tweet_id": "1253069421322567681",
        "public_metrics": {
          "followers_count": 1036,
          "following_count": 1330,
          "tweet_count": 855,
          "listed_count": 26
        },
        "location": "London, UK",
        "name": "Aurelia Specker",
        "profile_image_url": "https://pbs.twimg.com/profile_images/1137517534104772608/8FBYgc6G_normal.jpg",
        "url": ""
      }
    ],
    "tweets": [
      {
        "lang": "en",
        "conversation_id": "1224709550214873090",
        "text": "📣 如果您喜欢我去年11月写的伦敦通勤教程,请查看使用 Twitter 新搜索 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": "Twitter Web App",
        "created_at": "2020-02-04T15:01:25.000Z"
      }
    ]
  }
}
I