인증
| 방식 | 적합한 용도 | 비공개 리스트 접근 가능 여부 |
|---|---|---|
| OAuth 2.0 App-Only | 공개 리스트 데이터 | 아니요 |
| OAuth 2.0 Authorization Code with PKCE | 사용자 대상 App | 예 (소유/팔로우) |
| OAuth 1.0a User Context | 레거시 통합 | 예 (소유/팔로우) |
요청 예시
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로 리스트 조회
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로 리스트 조회 |
| GET | /2/users/:id/owned_lists | 사용자가 소유한 리스트 조회 |
필드 및 expansions
기본 응답
{
"data": {
"id": "84839422",
"name": "Tech News"
}
}
사용 가능한 필드
list.fields
list.fields
| 필드 | 설명 |
|---|---|
created_at | 리스트가 생성된 타임스탬프 |
description | 리스트 설명 |
follower_count | 팔로워 수 |
member_count | 멤버 수 |
owner_id | 소유자의 사용자 id |
private | 리스트가 비공개인지 여부 |
user.fields (owner_id 확장 필요)
user.fields (owner_id 확장 필요)
| 필드 | 설명 |
|---|---|
username | 소유자의 @핸들 |
name | 소유자의 표시 이름 |
verified | 소유자의 인증 상태 |
profile_image_url | 소유자의 아바타 URL |
expansions를 사용한 예시
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")
# 소유자에 대한 expansion이 포함된 리스트 가져오기
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) # 소유자 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); // 소유자 User 객체가 포함됩니다
확장(expansions)을 포함한 응답
{
"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
}
]
}
}
필드 및 expansions 가이드
응답을 커스터마이징하는 방법을 자세히 알아보세요
페이지네이션
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`);
페이지네이션 가이드
페이지네이션에 대해 자세히 알아보기
비공개 리스트
- 비공개 리스트는 소유자만 볼 수 있습니다.
- 비공개 리스트의 상세 정보를 조회하려면 리스트 소유자 계정으로 인증해야 합니다.
private필드는 리스트가 비공개인지 여부를 나타냅니다.
오류 처리
| Status | 오류 | 해결 방법 |
|---|---|---|
| 400 | 잘못된 요청 | 리스트 ID 형식을 확인하세요 |
| 401 | 인증 실패 | 인증 정보를 확인하세요 |
| 403 | 접근이 거부됨 | 리스트가 비공개일 수 있습니다 |
| 404 | 찾을 수 없음 | 리스트가 존재하지 않습니다 |
| 429 | 요청이 너무 많음 | 잠시 기다렸다가 다시 시도하세요 |
다음 단계
빠른 시작
첫 번째 리스트 조회 요청을 보내세요
리스트 포스트
리스트에서 포스트를 가져오기
API 참조 문서
엔드포인트 전체 문서
샘플 코드
실행 가능한 코드 예제