比较 X API 的 Post 计数 endpoint
v2 Post 计数 endpoint 未来将取代 Enterprise Search API 的 counts endpoint。如果你有使用旧版 Post 计数 endpoint 的代码、App 或工具,并考虑迁移到更新的 X API v2 endpoint,那么本指南适合你。 本页包含两张对比表:近期 Post 计数比较
Post 计数 endpoint 的 Enterprise 版本允许你获取最近 30 天或全量归档的计数。因此,只查看 7 天时间范围的 v2 近期 Post 计数 endpoint,并不能直接替代前述任一 endpoint。 不过,为了便于对比,我们将看看 v2 近期 Post 计数 endpoint 与 Enterprise 的 30 天 endpoint 如何比较。 下表比较了不同类型的近期 Post 计数 endpoint:Description | Enterprise | X API v2 |
---|---|---|
Host domain | https://gnip-api.x.com | https://api.x.com |
Endpoint path | /search/30day/accounts/:account_name/:label/counts.json | /2/tweets/counts/recent |
Authentication | 基本身份验证 | OAuth 2.0 Bearer Token |
Timestamp format | YYYYMMDDhhmm | YYYY-MM-DDTHH:mm:ssZ ISO 8601 / RFC 3339 |
Returns counts of Posts that are no older than | 31 天 | 7 天 |
HTTP methods supported | GET | GET |
Default request rate limits | 每秒 20 次请求,跨搜索数据与计数请求汇总计算 每分钟的请求速率限制因合作伙伴而异,具体以你的合同为准。 | 每用户每 15 分钟 180 次请求 每 App 每 15 分钟 450 次请求 |
Supports filtering using annotations | ✔ | |
Supports filtering using conversation_id | ✔ | |
JSON key name for Post data array | results | data |
Time granularity | 天、小时或分钟 | 天、小时或分钟 |
Timezone | UTC | UTC |
Request parameters for selecting time period | fromDate toDate | start_time end_time |
Request parameters for navigating by Post ID | since_id until_id | |
Requires the use of credentials from a developer App associated with a project | ✔ |
全量归档 Post 计数对比
下表对比了不同类型的全量归档搜索 endpoint:描述 | Enterprise | X API v2 |
---|---|---|
主机域名 | https://gnip-api.x.com | https://api.x.com |
Endpoint 路径 | /search/fullarchive/accounts/:account_name/:label/counts | /2/tweets/counts/all |
Authentication | 基本认证(Basic auth) | OAuth 2.0 Bearer Token |
时间戳格式 | YYYYMMDDHHMM | YYYY-MM-DDTHH:mm:ssZ ISO 8601 / RFC 3339 |
返回的 Post 计数不早于 | 自 2006 年 3 月起的完整归档 | 自 2006 年 3 月起的完整归档 |
支持的 HTTP 方法 | GET POST | GET |
默认请求速率限制 | 每分钟的请求速率限制将根据你的合同中约定的合作伙伴配置而有所不同。 20 requests per sec | 每 App 每 15 分钟 300 次请求 每 App 每 1 秒 1 次请求 |
粒度 | 天、小时、分钟 | 天、小时、分钟 |
支持使用 annotations 进行过滤 | ✔ | |
支持使用 conversation_id 进行过滤 | ✔ | |
用于 Post 数据数组的 JSON 键名 | results | data |
选择时间范围的请求参数 | fromDate toDate | start_time end_time |
按 Post ID 导航的请求参数 | since_id until_id | |
用于分页的 JSON 键名 | next | meta.next_token |
分页的请求参数 | next_token | next_token 或 pagination_token |
时区 | UTC | UTC |
需要使用与具有 Academic Research access 的 Project 关联的 developer App 的凭据 | ✔ |
过滤运算符对比
Enterprise 和 v2 两个版本的 Post 计数在可用运算符上存在差异;且各版本内部的运算符可用级别也不同,详见下文说明。 Enterprise- Enterprise 运算符没有子级。所有 Enterprise 运算符对所有 Enterprise 用户均可用。
- 核心(Core):这些运算符对任何 v2 用户均可用。
- 高级(Advanced):这些运算符仅对已获批学术研究(Academic Research)访问权限的用户可用。
Enterprise | v2 | |
---|---|---|
keyword | Available | Core |
emoji | Available | Core |
“exact phrase” | Available | Core |
# | Available | Core |
$ | Available | Advanced |
@ | Available | Core |
from: | Available | Core |
to: | Available | Core |
url: | Available | Core |
retweets_of: | Available | Core |
context: | Core | |
entity: | Core - Only available with recent search | |
conversation_id: | Core | |
place: | Available | Advanced |
place_country: | Available | Advanced |
point_radius: | Available | Advanced |
bounding_box: | Available | Advanced |
is:retweet | Available | Core |
is:reply | Available | Core |
is:quote | Available | Core |
is:verified | Available | Core |
-is:nullcast | Available | Advanced |
has:hashtags | Available | Core |
has:cashtags | Available | Advanced |
has:links | Available | Core |
has:mentions | Available | Core |
has:media | Available | Core |
has:images | Available | Core |
has:videos | Available | Core |
has:geo | Available | Advanced |
lang: | Available | Core |
list: | Advanced | |
has:profile_geo | Available | |
profile_country | Available | |
profile_locality | Available | |
profile_region | Available | |
proximity | Available |