API Hop ドキュメント
ユーザータイムラインの取得
ユーザー ID で Twitter のタイムラインを照会し、正規化されたツイート、投稿者の展開情報、ページネーションのメタデータを取得します。
https://api.apihop.ai/v1/twitter/users/{id}/tweets正規化されたユーザー ID でユーザーのタイムラインを照会します。このエンドポイントは、X API v2 形式の data / includes / meta 構造を返します。
GET https://api.apihop.ai/v1/twitter/users/{id}/tweets認証
すべての Twitter API エンドポイントに Bearer Token 認証が必要です。
Authorization: Bearer YOUR_API_KEYパスパラメータ
idstring必須44196397 などの Twitter ユーザー ID です。
クエリパラメータ
max_resultsinteger既定値: 101 ページに返すツイートの数です。1 から 100 を指定します。
pagination_tokenstring次のページのカーソルです。直前のレスポンスの meta.next_token からコピーしてください。
excludestring除外条件をカンマで区切って指定します。replies と retweets に対応しています。
expansionsstring展開するフィールドをカンマで区切って指定します。includes.users を含めるには author_id を使用してください。
tweet.fieldsstringcreated_at,public_metrics,attachments,source のように、ツイートフィールドをカンマで区切って指定します。
user.fieldsstringexpansions=author_id を指定したときの includes.users のフィールドを制御します。
リクエスト例
curl --request GET \
"$API_BASE_URL/v1/twitter/users/44196397/tweets?max_results=5&exclude=retweets,replies&expansions=author_id&tweet.fields=created_at,public_metrics,attachments,author_id,conversation_id&user.fields=public_metrics" \
--header "Authorization: Bearer YOUR_API_KEY"レスポンス
dataobject[]必須タイムラインのツイート一覧です。
ツイートのフィールド
idstring必須ツイート ID です。
textstring必須ツイートの本文です。
attachmentsobjectメディアへの参照です。現在は media_keys として返されます。
author_idstring投稿者 ID です。expansions=author_id を指定した場合、includes.users に対応します。
conversation_idstring会話 ID です。
created_atstringISO 8601 形式のツイート作成日時です。
edit_history_tweet_idsstring[]編集履歴に含まれるツイート ID です。
entitiesobjectハッシュタグ、URL、メンションなど、解析されたツイートのエンティティです。
in_reply_to_user_idstring返信先のユーザー ID です。
langstringツイートの言語です。
possibly_sensitiveboolean内容がセンシティブかどうかを示します。
public_metricsobjectツイートの公開指標です。
public_metrics のフィールド
retweet_countintegerリツイート数です。
reply_countinteger返信数です。
like_countintegerいいねの数です。
quote_countinteger引用数です。
bookmark_countintegerブックマーク数です。
impression_countinteger表示回数です。
referenced_tweetsobject[]参照されているツイートです。type は retweeted、quoted、replied_to のいずれかになります。
sourcestringクライアントやウェブなど、ツイートの投稿元です。
includesobject展開されたオブジェクトです。expansions に author_id が含まれる場合に表示されます。
includes のフィールド
usersobject[]author_id に対応する投稿者の一覧です。
metaobject必須ページネーションと結果のメタデータです。
meta のフィールド
newest_idstring現在のページで最も新しいツイートの ID です。
oldest_idstring現在のページで最も古いツイートの ID です。
next_tokenstring次のページのカーソルです。pagination_token として送信してください。
result_countinteger必須現在のページに含まれるツイートの数です。
成功時の例
{
"data": [
{
"id": "tweet-1",
"text": "Hello Mars",
"author_id": "44196397",
"created_at": "2025-04-22T10:00:00.000Z",
"public_metrics": {
"retweet_count": 3,
"reply_count": 2,
"like_count": 7
}
}
],
"includes": {
"users": [
{
"id": "44196397",
"name": "Elon Musk",
"username": "elonmusk"
}
]
},
"meta": {
"newest_id": "tweet-1",
"oldest_id": "tweet-1",
"next_token": "cursor-123",
"result_count": 1
}
}エラーレスポンス
コードの一覧、プロトコルごとの違い、診断手順については、エラーコードとトラブルシューティングを参照してください。
{
"success": false,
"error": {
"code": 40000,
"message": "Insufficient credit. Required: 100000, Available: 99999"
},
"requestId": "req_xxx"
}ページネーション
meta.next_token が含まれている場合は、その値を pagination_token として渡すと次のページを取得できます。