인증
List lookup 엔드포인트는 여러 인증 방식을 지원합니다:| Method | Best for | Access to private Lists? |
|---|---|---|
| OAuth 2.0 App-Only | 공개 List 데이터 | No |
| OAuth 2.0 Authorization Code with PKCE | 사용자 대상 앱 | Yes (소유/팔로우) |
| OAuth 1.0a User Context | 레거시 통합 | Yes (소유/팔로우) |
요청 예시
cURL
curl "https://api.x.com/2/lists/84839422?\
list.fields=description,member_count,follower_count,private" \
-H "Authorization: Bearer $BEARER_TOKEN"
from xdk import Client
client = Client(bearer_token="YOUR_BEARER_TOKEN")
# ID로 List 가져오기
response = client.lists.get(
list_id="84839422",
list_fields=["description", "member_count", "follower_count", "private"]
)
print(response.data)
import { Client } from "@xdevplatform/xdk";
const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });
const response = await client.lists.get("84839422", {
listFields: ["description", "member_count", "follower_count", "private"],
});
console.log(response.data);
엔드포인트 개요
| Method | Endpoint | Description |
|---|---|---|
| GET | /2/lists/:id | ID로 List 가져오기 |
| GET | /2/users/:id/owned_lists | 사용자가 소유한 List 가져오기 |
필드 및 확장
기본 응답
{
"data": {
"id": "84839422",
"name": "Tech News"
}
}
사용 가능한 필드
list.fields
list.fields
| Field | Description |
|---|---|
created_at | List 생성 타임스탬프 |
description | List 설명 |
follower_count | 팔로워 수 |
member_count | 멤버 수 |
owner_id | 소유자의 사용자 ID |
private | List가 비공개인지 여부 |
user.fields (owner_id expansion 필요)
user.fields (owner_id expansion 필요)
| Field | Description |
|---|---|
username | 소유자의 @handle |
name | 소유자의 표시 이름 |
verified | 소유자의 인증 상태 |
profile_image_url | 소유자의 아바타 URL |
expansion을 사용한 예시
cURL
curl "https://api.x.com/2/lists/84839422?\
list.fields=description,member_count,follower_count,owner_id&\
expansions=owner_id&\
user.fields=username,verified" \
-H "Authorization: Bearer $BEARER_TOKEN"
from xdk import Client
client = Client(bearer_token="YOUR_BEARER_TOKEN")
# owner expansion과 함께 List 가져오기
response = client.lists.get(
list_id="84839422",
list_fields=["description", "member_count", "follower_count", "owner_id"],
expansions=["owner_id"],
user_fields=["username", "verified"]
)
print(response.data)
print(response.includes) # owner user 객체 포함
import { Client } from "@xdevplatform/xdk";
const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });
const response = await client.lists.get("84839422", {
listFields: ["description", "member_count", "follower_count", "owner_id"],
expansions: ["owner_id"],
userFields: ["username", "verified"],
});
console.log(response.data);
console.log(response.includes); // owner user 객체 포함
expansion이 포함된 응답
{
"data": {
"id": "84839422",
"name": "Tech News",
"description": "Top tech journalists",
"member_count": 50,
"follower_count": 1250,
"owner_id": "2244994945"
},
"includes": {
"users": [
{
"id": "2244994945",
"username": "XDevelopers",
"verified": true
}
]
}
}
Fields 및 expansions 가이드
응답 커스터마이징에 대해 자세히 알아보기
페이지네이션
소유한 List를 조회할 때 결과는 페이지네이션됩니다:cURL
# 첫 번째 요청
curl "https://api.x.com/2/users/123/owned_lists?max_results=100" \
-H "Authorization: Bearer $BEARER_TOKEN"
# 페이지네이션 토큰을 사용한 다음 요청
curl "https://api.x.com/2/users/123/owned_lists?max_results=100&pagination_token=NEXT_TOKEN" \
-H "Authorization: Bearer $BEARER_TOKEN"
from xdk import Client
client = Client(bearer_token="YOUR_BEARER_TOKEN")
# SDK가 페이지네이션을 자동으로 처리
all_lists = []
for page in client.lists.get_user_owned_lists(user_id="123", max_results=100):
if page.data:
all_lists.extend(page.data)
print(f"Found {len(all_lists)} lists")
import { Client } from "@xdevplatform/xdk";
const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });
async function getAllOwnedLists(userId) {
const allLists = [];
// SDK가 페이지네이션을 자동으로 처리
const paginator = client.lists.getUserOwnedLists(userId, { maxResults: 100 });
for await (const page of paginator) {
if (page.data) {
allLists.push(...page.data);
}
}
return allLists;
}
// 사용 예시
const lists = await getAllOwnedLists("123");
console.log(`Found ${lists.length} lists`);
페이지네이션 가이드
페이지네이션에 대해 자세히 알아보기
비공개 List
- 비공개 List는 소유자에게만 표시됩니다
- 비공개 List의 세부 정보를 조회하려면 소유자로 인증해야 합니다
private필드는 List가 비공개인지 여부를 나타냅니다
오류 처리
| Status | Error | Solution |
|---|---|---|
| 400 | Invalid request | List ID 형식 확인 |
| 401 | Unauthorized | 인증 확인 |
| 403 | Forbidden | List가 비공개일 수 있음 |
| 404 | Not Found | List가 존재하지 않음 |
| 429 | Too Many Requests | 잠시 후 재시도 |
다음 단계
퀵스타트
첫 List lookup 요청 만들기
List Posts
List에서 Post 가져오기
API 레퍼런스
전체 엔드포인트 문서
예제 코드
동작하는 코드 예제