API Hop

ドキュメント

API Hop ドキュメント

ID によるユーザー取得

ユーザー ID で Twitter のプロフィールを照会し、正規化された X API v2 形式のユーザーオブジェクトを取得します。

GEThttps://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必須

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

クエリパラメータ

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_atstring

ISO 8601 形式のタイムスタンプです。user.fields=created_at を指定した場合に返されます。

descriptionstring

ユーザーの自己紹介です。

entitiesobject

URL の説明やリンクなど、プロフィールに含まれるエンティティです。

locationstring

ユーザープロフィールの所在地です。

pinned_tweet_idstring

固定されたツイートの ID です。

profile_banner_urlstring

プロフィールのバナー画像 URL です。

profile_image_urlstring

プロフィール画像の URL です。

protectedboolean

アカウントが非公開かどうかを示します。

public_metricsobject

ユーザーの公開指標です。

public_metrics のフィールド
followers_countinteger

フォロワー数です。

following_countinteger

フォローしているアカウント数です。

tweet_countinteger

ツイートの総数です。

listed_countinteger

このユーザーを含むリストの数です。データソースが提供しない場合は含まれないことがあります。

urlstring

ユーザープロフィールに記載されたウェブサイトの URL です。

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} リソースとして扱いたい場合