Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 1.93 KB

File metadata and controls

53 lines (45 loc) · 1.93 KB

X API 文档

通用约定

  • Base URL: https://x.com
  • GraphQL URL: /i/api/graphql/{queryId}/{operationName}
  • 大多数接口需要登录 Cookie、Bearer Authorization、x-csrf-token
  • x-csrf-token 通常等于 Cookie 中的 ct0
  • 返回外层通常为 X 原始 JSON。测试脚本会直接输出接口返回内容:
{
  "code": 0,
  "message": "error message when failed",
  "data": {}
}

当前接口

常用请求头

authorization: Bearer ...
Cookie: ...
x-csrf-token: <ct0>
x-twitter-active-user: yes
x-twitter-auth-type: OAuth2Session
x-twitter-client-language: zh-cn
User-Agent: Mozilla/5.0 ...

部分接口还需要当前页面生成的 x-client-transaction-id。Python 测试脚本支持通过 X_CLIENT_TRANSACTION_ID 环境变量传入;没有该值时,部分写入或搜索接口可能被 X 拒绝。