메인 콘텐츠로 건너뛰기
이 가이드는 X API v2를 사용하여 처음으로 게시물 조회 요청을 보내는 방법을 단계별로 안내합니다.
사전 준비 사항시작하기 전에 다음이 필요합니다.
  • 승인된 App이 있는 개발자 계정
  • 개발자 콘솔의 “Keys and tokens”에서 확인할 수 있는 App의 Bearer 토큰

1

게시물 ID 찾기

모든 게시물에는 고유한 식별자(id)가 있습니다. 이 식별자는 게시물의 URL에서 확인할 수 있습니다:
https://x.com/XDevelopers/status/1228393702244134912
                                └── 이것이 게시물 ID입니다
2

요청하기

cURL
curl "https://api.x.com/2/tweets/1228393702244134912" \
  -H "Authorization: Bearer $BEARER_TOKEN"
3

응답을 검토하세요

기본 응답에는 해당 게시물의 id, text, edit_history_tweet_ids가 포함됩니다:
{
  "data": {
    "id": "1228393702244134912",
    "text": "What did the developer write in their Valentine's card?\n\nwhile(true) {\n    I = Love(You);\n}",
    "edit_history_tweet_ids": ["1228393702244134912"]
  }
}
4

추가 필드 요청하기

더 많은 데이터를 조회하려면 쿼리 매개변수를 사용하세요:
cURL
curl "https://api.x.com/2/tweets/1228393702244134912?\
tweet.fields=created_at,public_metrics,author_id&\
expansions=author_id&\
user.fields=username,verified" \
  -H "Authorization: Bearer $BEARER_TOKEN"
응답:
{
  "data": {
    "id": "1228393702244134912",
    "text": "What did the developer write in their Valentine's card?...",
    "created_at": "2020-02-14T19:00:55.000Z",
    "author_id": "2244994945",
    "public_metrics": {
      "retweet_count": 156,
      "reply_count": 23,
      "like_count": 892,
      "quote_count": 12
    },
    "edit_history_tweet_ids": ["1228393702244134912"]
  },
  "includes": {
    "users": [
      {
        "id": "2244994945",
        "username": "XDevelopers",
        "verified": true
      }
    ]
  }
}
5

여러 포스트 조회

한 번의 요청으로 최대 100개의 포스트를 조회합니다:
cURL
curl "https://api.x.com/2/tweets?\
ids=1228393702244134912,1227640996038684673,1199786642791452673&\
tweet.fields=created_at,author_id" \
  -H "Authorization: Bearer $BEARER_TOKEN"

다음 단계

연동 가이드

인증, 요청 한도 및 모범 사례를 익히세요

필드 및 expansions

필드 및 expansions 시스템을 마스터하세요

API 참조 문서

사용 가능한 모든 매개변수를 확인하세요

샘플 코드

더 많은 예제를 살펴보세요