API Hop

文件目錄

API Hop 文件

Twitter API

透過統一的 Twitter API,以 X API v2 回應結構查詢使用者個人資料與時間軸。

本服務提供統一的 Twitter REST API,呼叫端會取得一致的 X API v2 風格回應結構。

text
/v1/twitter

驗證

所有 Twitter API 端點均需要 Bearer Token 驗證。

http
Authorization: Bearer YOUR_API_KEY

基礎路徑

請在 API 基礎網址下呼叫這些相對路徑。

text
GET https://api.apihop.ai/v1/twitter/users
GET https://api.apihop.ai/v1/twitter/users/{id}
GET https://api.apihop.ai/v1/twitter/users/{id}/tweets

回應結構

Twitter 成功回應不會包在 success/data 中,而是直接傳回正規化的 data、includes 與 meta 欄位。

支援能力

  1. 若只有 username,請先依使用者名稱查詢使用者,並讀取 data.id。
  2. 使用 data.id 查詢使用者時間軸。
  3. 若時間軸回應需要作者個人資料,請傳入 expansions=author_id。

正規化規則

  • 使用者端點傳回單一使用者物件:{ "data": { ... } }
  • 時間軸端點傳回推文陣列:{ "data": [ ... ], "meta": { ... } }
  • 請求 expansions=author_id 時,時間軸回應會包含 includes.users
  • user.fields 與 tweet.fields 控制選填欄位的選取
  • 使用者物件一律保留 id、name 與 username
  • 推文物件一律保留 id 與 text

選填欄位

user.fields

支援的正規化使用者欄位:

  • created_at
  • description
  • entities
  • location
  • pinned_tweet_id
  • profile_banner_url
  • profile_image_url
  • protected
  • public_metrics
  • url
  • verified
  • verified_type

tweet.fields

支援的正規化推文欄位:

  • attachments
  • author_id
  • conversation_id
  • created_at
  • edit_history_tweet_ids
  • entities
  • in_reply_to_user_id
  • lang
  • possibly_sensitive
  • public_metrics
  • referenced_tweets
  • source

除錯

  • 每個回應均包含 X-Request-Id
  • 呼叫失敗、結果異常或遇到速率限制時,請記錄此值
  • 詢問計費問題時,請保留 X-Request-Id 與請求時間

端點