사전 요구사항시작하기 전에 다음이 필요합니다:
- 승인된 App이 포함된 developer account
- User Access Token (OAuth 1.0a 또는 OAuth 2.0 PKCE)
List 생성
1
요청 준비
List 이름(필수)과 선택적 설명 및 비공개 설정을 정의합니다:
{
"name": "Tech News",
"description": "Top tech journalists and publications",
"private": false
}
2
요청 보내기
cURL
curl -X POST "https://api.x.com/2/lists" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Tech News",
"description": "Top tech journalists and publications",
"private": false
}'
from xdk import Client
from xdk.oauth1_auth import OAuth1
oauth1 = OAuth1(
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
access_token="YOUR_ACCESS_TOKEN",
access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
)
client = Client(auth=oauth1)
# 새 List 생성
response = client.lists.create(
name="Tech News",
description="Top tech journalists and publications",
private=False
)
print(f"List created: {response.data.id} - {response.data.name}")
import { Client, OAuth1 } from "@xdevplatform/xdk";
const oauth1 = new OAuth1({
apiKey: "YOUR_API_KEY",
apiSecret: "YOUR_API_SECRET",
accessToken: "YOUR_ACCESS_TOKEN",
accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
});
const client = new Client({ oauth1 });
// 새 List 생성
const response = await client.lists.create({
name: "Tech News",
description: "Top tech journalists and publications",
private: false,
});
console.log(`List created: ${response.data?.id} - ${response.data?.name}`);
3
응답 확인
{
"data": {
"id": "1441162269824405510",
"name": "Tech News"
}
}
id를 저장하세요.List 업데이트
List의 이름, 설명 또는 비공개 여부 수정:cURL
curl -X PUT "https://api.x.com/2/lists/1441162269824405510" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Tech News & Insights",
"description": "Updated description"
}'
from xdk import Client
from xdk.oauth1_auth import OAuth1
oauth1 = OAuth1(
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
access_token="YOUR_ACCESS_TOKEN",
access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
)
client = Client(auth=oauth1)
# List 업데이트
response = client.lists.update(
"1441162269824405510",
name="Tech News & Insights",
description="Updated description"
)
print(f"Updated: {response.data.updated}")
import { Client, OAuth1 } from "@xdevplatform/xdk";
const oauth1 = new OAuth1({
apiKey: "YOUR_API_KEY",
apiSecret: "YOUR_API_SECRET",
accessToken: "YOUR_ACCESS_TOKEN",
accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
});
const client = new Client({ oauth1 });
// List 업데이트
const response = await client.lists.update("1441162269824405510", {
name: "Tech News & Insights",
description: "Updated description",
});
console.log(`Updated: ${response.data?.updated}`);
{
"data": {
"updated": true
}
}
List 삭제
1
List ID 가져오기
삭제하려는 List의 ID가 필요합니다.
2
삭제 요청 보내기
cURL
curl -X DELETE "https://api.x.com/2/lists/1441162269824405510" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN"
from xdk import Client
from xdk.oauth1_auth import OAuth1
oauth1 = OAuth1(
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
access_token="YOUR_ACCESS_TOKEN",
access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
)
client = Client(auth=oauth1)
# List 삭제
response = client.lists.delete("1441162269824405510")
print(f"Deleted: {response.data.deleted}")
import { Client, OAuth1 } from "@xdevplatform/xdk";
const oauth1 = new OAuth1({
apiKey: "YOUR_API_KEY",
apiSecret: "YOUR_API_SECRET",
accessToken: "YOUR_ACCESS_TOKEN",
accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
});
const client = new Client({ oauth1 });
// List 삭제
const response = await client.lists.delete("1441162269824405510");
console.log(`Deleted: ${response.data?.deleted}`);
3
삭제 확인
{
"data": {
"deleted": true
}
}
소유한 List만 삭제할 수 있습니다.
다음 단계
List 멤버
List 멤버 추가 및 제거
List lookup
List 세부 정보 조회
통합 가이드
핵심 개념 및 모범 사례
API 레퍼런스
전체 엔드포인트 문서