API Hop 文件
依 ID 查詢使用者
依使用者 ID 查詢 Twitter 個人資料,並傳回正規化的 X API v2 風格使用者物件。
GET
https://api.apihop.ai/v1/twitter/users/{id}已知正規化的使用者 ID 時,請直接查詢此資源,不必再次解析使用者名稱。
text
GET https://api.apihop.ai/v1/twitter/users/{id}驗證
所有 Twitter API 端點均需要 Bearer Token 驗證。
http
Authorization: Bearer YOUR_API_KEY路徑參數
idstring必填Twitter 使用者 ID,例如 44196397。
查詢參數
user.fieldsstring以逗號分隔的使用者欄位,例如 verified,public_metrics,profile_image_url。
請求範例
bash
curl --request GET \
"$API_BASE_URL/v1/twitter/users/44196397?user.fields=verified,public_metrics,profile_image_url" \
--header "Authorization: Bearer YOUR_API_KEY"回應
dataobject必填正規化的使用者物件。
data 欄位
idstring必填使用者的唯一識別碼。
namestring必填顯示名稱。
usernamestring必填不含 @ 的使用者名稱。
created_atstringISO 8601 時間戳記,在請求 user.fields=created_at 時傳回。
descriptionstring使用者簡介。
entitiesobject個人資料實體,例如網址說明與連結。
locationstring使用者個人資料中的所在地。
pinned_tweet_idstring置頂推文的 ID。
profile_banner_urlstring個人資料橫幅網址。
profile_image_urlstring個人資料圖片網址。
protectedboolean帳號是否受到保護。
public_metricsobject公開使用者指標。
public_metrics 欄位
followers_countinteger追蹤者人數。
following_countinteger追蹤的帳號數量。
tweet_countinteger推文總數。
listed_countinteger包含此使用者的列表數量。資料來源未提供時可能缺少此欄位。
urlstring使用者個人資料中的網站網址。
verifiedboolean帳號是否已驗證。
verified_typestring驗證類型,例如 Business。
成功範例
json
{
"data": {
"id": "44196397",
"name": "Elon Musk",
"username": "elonmusk",
"profile_image_url": "https://img.example/profile.jpg",
"public_metrics": {
"followers_count": 10,
"following_count": 20,
"tweet_count": 40
},
"verified": true
}
}錯誤回應
完整代碼參考、協定差異及診斷步驟,請見錯誤代碼與疑難排解。
json
{
"success": false,
"error": {
"code": 40000,
"message": "Insufficient credit. Required: 100000, Available: 99999"
},
"requestId": "req_xxx"
}適用時機
- 您已取得使用者的
id - 您希望避免使用者名稱變更帶來的影響
- 您希望將
User Info視為標準的/users/{id}資源