API Hop

ドキュメント

API Hop ドキュメント

ユーザータイムラインの取得

ユーザー ID で Twitter のタイムラインを照会し、正規化されたツイート、投稿者の展開情報、ページネーションのメタデータを取得します。

GEThttps://api.apihop.ai/v1/twitter/users/{id}/tweets

正規化されたユーザー ID でユーザーのタイムラインを照会します。このエンドポイントは、X API v2 形式の data / includes / meta 構造を返します。

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

認証

すべての Twitter API エンドポイントに Bearer Token 認証が必要です。

http
Authorization: Bearer YOUR_API_KEY

パスパラメータ

idstring必須

44196397 などの Twitter ユーザー ID です。

クエリパラメータ

max_resultsinteger既定値: 10

1 ページに返すツイートの数です。1 から 100 を指定します。

pagination_tokenstring

次のページのカーソルです。直前のレスポンスの meta.next_token からコピーしてください。

excludestring

除外条件をカンマで区切って指定します。replies と retweets に対応しています。

expansionsstring

展開するフィールドをカンマで区切って指定します。includes.users を含めるには author_id を使用してください。

tweet.fieldsstring

created_at,public_metrics,attachments,source のように、ツイートフィールドをカンマで区切って指定します。

user.fieldsstring

expansions=author_id を指定したときの includes.users のフィールドを制御します。

リクエスト例

bash
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_atstring

ISO 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必須

現在のページに含まれるツイートの数です。

成功時の例

json
{
  "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
  }
}

エラーレスポンス

コードの一覧、プロトコルごとの違い、診断手順については、エラーコードとトラブルシューティングを参照してください。

json
{
  "success": false,
  "error": {
    "code": 40000,
    "message": "Insufficient credit. Required: 100000, Available: 99999"
  },
  "requestId": "req_xxx"
}

ページネーション

meta.next_token が含まれている場合は、その値を pagination_token として渡すと次のページを取得できます。