이 가이드는 리스트 타임라인에서 포스트를 가져오는 방법을 설명합니다.
사전 준비 사항시작하기 전에 다음이 필요합니다.
- 승인된 App이 있는 개발자 계정
- App의 Bearer 토큰
리스트 ID 찾기
x.com에서 리스트를 볼 때 URL에서 리스트 ID를 확인할 수 있습니다.https://x.com/i/lists/84839422
└── 이것이 리스트 ID입니다
리스트 타임라인 요청하기
curl "https://api.x.com/2/lists/84839422/tweets?\
tweet.fields=created_at,public_metrics,author_id&\
expansions=author_id&\
user.fields=username,verified&\
max_results=10" \
-H "Authorization: Bearer $BEARER_TOKEN"
응답 검토하기
{
"data": [
{
"id": "1458172421115101189",
"text": "Check out our latest announcement...",
"author_id": "4172587277",
"created_at": "2024-01-15T10:30:00.000Z",
"public_metrics": {
"retweet_count": 42,
"reply_count": 5,
"like_count": 156,
"quote_count": 3
},
"edit_history_tweet_ids": ["1458172421115101189"]
}
],
"includes": {
"users": [
{
"id": "4172587277",
"username": "TechNews",
"verified": true
}
]
},
"meta": {
"result_count": 1,
"next_token": "7140dibdnow9c7btw3z2vwioavpvutgzrzm9icis4ndix"
}
}
결과 페이지네이션하기
SDK는 페이지네이션을 자동으로 처리합니다. cURL을 사용할 경우, 더 많은 포스트를 가져오려면 응답에 포함된 next_token을 사용합니다.curl "https://api.x.com/2/lists/84839422/tweets?\
max_results=10&\
pagination_token=7140dibdnow9c7btw3z2vwioavpvutgzrzm9icis4ndix" \
-H "Authorization: Bearer $BEARER_TOKEN"
이 엔드포인트는 해당 리스트에서 가장 최근 포스트를 최대 800개까지 반환합니다.