이 가이드는 팔로워 및 팔로잉 리스트를 조회하고 팔로우를 관리하는 방법을 단계별로 설명합니다.
사전 준비 사항시작하기 전에 다음이 필요합니다:
- 승인된 App이 포함된 개발자 계정
- 조회를 위한 App의 Bearer 토큰
- 팔로우 관리를 위한 사용자 액세스 토큰(User Access Token)
특정 사용자를 팔로우하는 사용자 목록을 조회합니다:
curl "https://api.x.com/2/users/2244994945/followers?\
user.fields=username,verified,public_metrics&\
max_results=100" \
-H "Authorization: Bearer $BEARER_TOKEN"
{
"data": [
{
"id": "1234567890",
"name": "Developer",
"username": "dev_user",
"verified": false,
"public_metrics": {
"followers_count": 500,
"following_count": 200,
"tweet_count": 1500
}
}
],
"meta": {
"result_count": 1,
"next_token": "abc123"
}
}
특정 사용자가 팔로우하는 사용자 목록을 조회합니다.
curl "https://api.x.com/2/users/2244994945/following?\
user.fields=username,verified&\
max_results=100" \
-H "Authorization: Bearer $BEARER_TOKEN"
인증된 사용자 계정을 대신해 다른 사용자를 팔로우합니다:
curl -X POST "https://api.x.com/2/users/123456789/following" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"target_user_id": "2244994945"}'
{
"data": {
"following": true,
"pending_follow": false
}
}
대상 계정이 보호된 계정인 경우 팔로우 요청이 승인될 때까지 pending_follow는 true로 유지됩니다.
인증된 사용자 계정을 대신해 다른 사용자를 언팔로우합니다:
curl -X DELETE "https://api.x.com/2/users/123456789/following/2244994945" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN"
{
"data": {
"following": false
}
}
| 매개변수 | 설명 |
|---|
max_results | 페이지당 결과 수(1-1000, 기본값 100) |
pagination_token | 다음 페이지를 가져오기 위한 토큰 |
user.fields | 추가 사용자 필드 |
expansions | 포함할 관련 객체 |