이 가이드는 2006년 3월까지 거슬러 올라가는 X 전체 아카이브에서 포스트를 찾을 수 있도록, 첫 전체 아카이브 검색 요청을 만드는 과정을 단계별로 설명합니다.
사전 준비 사항 시작하기 전에 다음이 필요합니다:
개발자 계정
개발자 콘솔의 “Keys and tokens” 섹션에서 확인할 수 있는 App의 Bearer 토큰
전체 아카이브 검색에서는 모든 쿼리 연산자를 지원합니다. 최근 검색과 동일한 방식으로 쿼리를 작성하세요:
전체 아카이브 검색은 길이 1,024자까지의 쿼리(Enterprise의 경우 4,096자까지)를 지원합니다.
기본적으로 검색 결과에는 지난 30일 이내의 포스트만 포함됩니다. 특정 기간을 검색하려면 start_time과 end_time을 사용하세요:
Parameter Format Example start_timeISO 8601 2020-01-01T00:00:00Zend_timeISO 8601 2020-12-31T23:59:59Z
curl "https://api.x.com/2/tweets/search/all? \
query=from%3AXDevelopers& \
start_time=2020-01-01T00%3A00%3A00Z& \
end_time=2020-12-31T23%3A59%3A59Z& \
max_results=100" \
-H "Authorization: Bearer $BEARER_TOKEN "
{
"data" : [
{
"id" : "1271111223220809728" ,
"text" : "Tune in tonight and watch as @jessicagarson takes us through..." ,
"edit_history_tweet_ids" : [ "1271111223220809728" ]
},
{
"id" : "1270799243071062016" ,
"text" : "As we work towards building the new Twitter API..." ,
"edit_history_tweet_ids" : [ "1270799243071062016" ]
}
],
"meta" : {
"newest_id" : "1271111223220809728" ,
"oldest_id" : "1270799243071062016" ,
"result_count" : 2
}
}
편집 기능이 2022년 9월에 도입되기 전에 생성된 게시물에는 edit_history_tweet_ids 필드가 포함되지 않습니다.
5단계: fields 및 expansions 추가
쿼리 매개변수를 사용해 추가 데이터를 요청합니다:
curl "https://api.x.com/2/tweets/search/all? \
query=from%3AXDevelopers& \
start_time=2020-01-01T00%3A00%3A00Z& \
end_time=2020-12-31T23%3A59%3A59Z& \
tweet.fields=created_at,public_metrics,author_id& \
expansions=author_id& \
user.fields=username,description& \
max_results=100" \
-H "Authorization: Bearer $BEARER_TOKEN "
SDK들은 페이지네이션을 자동으로 처리합니다. cURL을 사용할 때는 응답에 포함된 next_token 값을 사용하세요:
curl "https://api.x.com/2/tweets/search/all? \
query=from%3AXDevelopers& \
max_results=500& \
next_token=b26v89c19zqg8o3fo7gesq314yb9l2l4ptqy" \
-H "Authorization: Bearer $BEARER_TOKEN "
페이지네이션 가이드 대규모 결과를 효율적으로 탐색하는 방법을 알아보세요
기능 최근 검색 전체 아카이브 검색 시간 범위 최근 7일 2006년 3월부터 현재까지 필요한 액세스 권한 모든 개발자 사용량 기반 과금, Enterprise 요청당 최대 결과 수 100 500 쿼리 길이 512자 1,024자 요청 한도 450 / 15분 300 / 15분, 1 /초 인증 방식 App-Only, User Context App-Only만
Parameter Description Default query검색 쿼리 (필수) — max_results페이지당 포스트 수 (10-500) 10 start_time가장 오래된 게시물의 타임스탬프 30일 전 end_time가장 최신 게시물의 타임스탬프 현재 next_token페이지네이션 토큰 — tweet.fields추가 게시물 필드 id, textexpansions포함할 관련 객체 —
API 참조 문서 전체 endpoint 문서 확인하기