ID로 List 가져오기
특정 List에 대한 세부 정보 조회:cURL
curl "https://api.x.com/2/lists/1234567890?\
list.fields=description,owner_id,member_count,follower_count,private,created_at" \
-H "Authorization: Bearer $BEARER_TOKEN"
from xdk import Client
client = Client(bearer_token="YOUR_BEARER_TOKEN")
# ID로 List 가져오기
response = client.lists.get(
"1234567890",
list_fields=["description", "owner_id", "member_count", "follower_count", "private", "created_at"]
)
print(f"List: {response.data.name}")
print(f"Members: {response.data.member_count}")
import { Client } from "@xdevplatform/xdk";
const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });
// ID로 List 가져오기
const response = await client.lists.get("1234567890", {
listFields: ["description", "owner_id", "member_count", "follower_count", "private", "created_at"],
});
console.log(`List: ${response.data?.name}`);
console.log(`Members: ${response.data?.member_count}`);
응답
{
"data": {
"id": "1234567890",
"name": "Tech News",
"description": "Top tech journalists and publications",
"owner_id": "2244994945",
"private": false,
"member_count": 50,
"follower_count": 1250,
"created_at": "2023-01-15T10:00:00.000Z"
}
}
사용자가 소유한 List 가져오기
특정 사용자가 소유한 모든 List 조회:cURL
curl "https://api.x.com/2/users/2244994945/owned_lists?\
list.fields=description,member_count,follower_count&\
max_results=100" \
-H "Authorization: Bearer $BEARER_TOKEN"
from xdk import Client
client = Client(bearer_token="YOUR_BEARER_TOKEN")
# 페이지네이션으로 사용자가 소유한 List 가져오기
for page in client.lists.get_owned_lists(
"2244994945",
list_fields=["description", "member_count", "follower_count"],
max_results=100
):
for lst in page.data:
print(f"{lst.name} - {lst.member_count} members")
import { Client } from "@xdevplatform/xdk";
const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });
// 페이지네이션으로 사용자가 소유한 List 가져오기
const paginator = client.lists.getOwnedLists("2244994945", {
listFields: ["description", "member_count", "follower_count"],
maxResults: 100,
});
for await (const page of paginator) {
page.data?.forEach((lst) => {
console.log(`${lst.name} - ${lst.member_count} members`);
});
}
응답
{
"data": [
{
"id": "1234567890",
"name": "Tech News",
"description": "Top tech journalists",
"member_count": 50,
"follower_count": 1250
},
{
"id": "9876543210",
"name": "Developer Tools",
"description": "Useful tools for developers",
"member_count": 25,
"follower_count": 500
}
],
"meta": {
"result_count": 2
}
}
소유자 정보 포함
소유자의 user 데이터 확장:cURL
curl "https://api.x.com/2/lists/1234567890?\
list.fields=description,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")
# 소유자 정보와 함께 List 가져오기
response = client.lists.get(
"1234567890",
list_fields=["description", "owner_id"],
expansions=["owner_id"],
user_fields=["username", "verified"]
)
print(f"List: {response.data.name}")
# 소유자 정보는 response.includes.users에 있음
import { Client } from "@xdevplatform/xdk";
const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });
// 소유자 정보와 함께 List 가져오기
const response = await client.lists.get("1234567890", {
listFields: ["description", "owner_id"],
expansions: ["owner_id"],
userFields: ["username", "verified"],
});
console.log(`List: ${response.data?.name}`);
// 소유자 정보는 response.includes?.users에 있음
expansion이 포함된 응답
{
"data": {
"id": "1234567890",
"name": "Tech News",
"description": "Top tech journalists",
"owner_id": "2244994945"
},
"includes": {
"users": [
{
"id": "2244994945",
"username": "XDevelopers",
"verified": true
}
]
}
}
사용 가능한 필드
| Field | Description |
|---|---|
description | List 설명 |
owner_id | 소유자의 사용자 ID |
private | List가 비공개인지 여부 |
member_count | 멤버 수 |
follower_count | 팔로워 수 |
created_at | List 생성 날짜 |
다음 단계
List Posts
List에서 Post 가져오기
List 멤버
List 멤버 가져오기
List 관리
List 생성 및 업데이트
API 레퍼런스
전체 엔드포인트 문서