打开英文 API 调试台(页面仅提供英文版)
按用户名查询
GET
/tw-v2/user/by-username说明
使用平台用户名获取完整的用户资料信息。返回详细的用户数据,包括统计指标、认证状态和资料元数据。
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| username | string | 必填 | 不含 @ 符号的平台用户名(例如 'sample_user_96991') |
代码示例
const params = new URLSearchParams({
username: 'sample_user_96991'
});
const response = await fetch(`https://api.tweetapi.com/tw-v2/user/by-username?${params}`, {
method: 'GET',
headers: {
'X-API-Key': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);响应
成功响应(200 OK)
200
{
"data": {
"id": "10017528",
"username": "sample_user_96991",
"name": "Sample User 96991",
"bio": "Sample profile bio for Sample User 96991.",
"location": null,
"website": null,
"pinnedTweetIds": [
"2001738170940982678"
],
"avatar": "https://example.com/images/sample-avatar-96991.jpg",
"banner": "https://example.com/images/sample-banner-96991.jpg",
"profileImageShape": "Circle",
"verified": false,
"isBlueVerified": true,
"verifiedType": null,
"verifiedSince": null,
"isIdentityVerified": false,
"isProtected": false,
"possiblySensitive": false,
"profileInterstitialType": null,
"withheldInCountries": [],
"professional": {
"type": "Creator",
"category": [],
"restId": "9001630152611040706"
},
"businessAccount": {
"affiliatesCount": 0
},
"creatorSubscriptionsCount": 225,
"hasHiddenSubscriptions": true,
"highlightsInfo": {
"canHighlight": true,
"highlightedTweetsCount": "758"
},
"hasGraduatedAccess": true,
"isProfileTranslatable": false,
"hasCustomTimelines": true,
"isTranslator": false,
"affiliatesHighlightedLabel": {
"label": {
"url": {
"url": "https://example.com/link-94089/profile-41921/X",
"urlType": "DeepLink"
},
"badge": {
"url": "https://example.com/link-94089/profile-29900/media/sample-media-25883.jpg"
},
"description": "Sample description for documentation 53418.",
"userLabelType": "BusinessLabel",
"userLabelDisplayType": "Badge"
}
},
"defaultProfile": false,
"defaultProfileImage": false,
"followerCount": 226995885,
"followingCount": 1218,
"tweetCount": 86745,
"listedCount": 164447,
"mediaCount": 4162,
"favoritesCount": 174837,
"createdAt": "2009-06-02T20:12:29.000Z"
}
}