Documentation Index
Fetch the complete documentation index at: https://generaltranslation.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
이 가이드는 X API를 사용하여 포스트를 생성하고 삭제하는 방법을 단계별로 안내합니다.
사전 준비 사항시작하기 전에 다음이 필요합니다.
- 승인된 App이 있는 개발자 계정
- 사용자 액세스 토큰(OAuth 1.0a 또는 OAuth 2.0 PKCE)
요청 준비하기
POST /2/tweets 엔드포인트를 호출하려면 JSON 본문에 최소한 text 또는 media 필드가 포함되어 있어야 합니다.{
"text": "Hello from the X API!"
}
요청 보내기
curl -X POST "https://api.x.com/2/tweets" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "Hello from the X API!"}'
응답 확인하기
성공한 응답에는 새 게시물의 id와 text가 포함됩니다.{
"data": {
"id": "1445880548472328192",
"text": "Hello from the X API!"
}
}
curl -X POST "https://api.x.com/2/tweets" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "This is a reply!",
"reply": {
"in_reply_to_tweet_id": "1234567890"
}
}'
curl -X POST "https://api.x.com/2/tweets" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "Check this out!",
"quote_tweet_id": "1234567890"
}'
먼저 Media Upload 엔드포인트를 사용해 미디어를 업로드한 다음, media_id를 참조합니다:curl -X POST "https://api.x.com/2/tweets" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "오늘의 사진!",
"media": {
"media_ids": ["1234567890123456789"]
}
}'
curl -X POST "https://api.x.com/2/tweets" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "가장 좋아하는 색은 무엇인가요?",
"poll": {
"options": ["빨강", "파랑", "초록", "노랑"],
"duration_minutes": 1440
}
}'
게시물 ID 가져오기
삭제하려는 게시물의 ID가 필요합니다. 이 값은 게시물을 생성할 때 반환됩니다.
DELETE 요청 보내기
curl -X DELETE "https://api.x.com/2/tweets/1445880548472328192" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN"
삭제 확인
{
"data": {
"deleted": true
}
}