如何从 Tenor 的 V1 API 迁移
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
对于使用 Tenor 的 V1 API 的现有集成,请按照本页面上的步骤迁移到 V2。
获取 V2 API 密钥
按照快速入门指南的设置步骤中的说明获取 V2 API 密钥,以替换您的 V1 版本。
更新为 V2 网域
将 API 网域更新为 https://tenor.googleapis.com/v2/
。Tenor 的 V2 API 仅支持 HTTPS 连接。对于内容,请确保您的应用支持从 https://media.tenor.com
和 https://c.tenor.com
下载内容。
例如,假设您向以下某个 V1 网域发出了 API 调用:
https://api.tenor.com/v1/search?<parameters>
https://g.tenor.com/v1/search?<parameters>
如需更新对 V2 的调用,请将其更改为 https://tenor.googleapis.com/v2/search?<parameters>
。
端点更改
大多数 API 端点参数与 V1 中记录的参数相同。不过,也有一些值得注意的例外情况:
- Tenor 的搜索端点现在支持通过
searchfilter
参数搜索贴纸。
- 在 API 调用中添加
client_key
和 country
参数。
media_filter
参数现在接受以英文逗号分隔的所需格式列表,而不是预设的枚举。
- “类别”端点现在支持
type
参数的 featured
和 trending
。
- 该 API 不再支持
anon_id
参数。
- 当没有更多结果页可供请求时,API 响应的
next
字段现在为空字符串,而不是 "0"
。
可用的端点已进行了以下更改:
- 热门趋势端点已不再受支持。我们建议您改用精选端点。
- GIF 端点已更名为帖子端点。
- 随机 GIF 端点已通过
random
参数并入搜索端点。
响应对象和错误变更
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-25。"],[],["To migrate from Tenor's V1 to V2 API, obtain a new V2 API key and update API domains to `https://tenor.googleapis.com/v2/`, ensuring support for content downloads from `https://media.tenor.com` and `https://c.tenor.com`. Key endpoint updates include sticker search via `searchfilter`, `client_key` and `country` parameters, comma-separated `media_filter` formats, and changes to Categories. `Trending` is replaced by `Featured`, `GIF` becomes `Posts`, `Random GIF` is under `Search`. Response object changes involve `media` to `media_formats` and updated error codes.\n"]]