X AI Search API
X(Twitter)를 두고 일상어로 던진 질문에 글로 답합니다. 근거로 삼은 X 게시물과 모델이 돌린 검색 횟수도 함께 나옵니다.
GET /v1/twitter/ai-searchX AI Search API는 언제 쓰나요
특정 계정이 이번 주에 어떤 주제로 뭐라고 했는지처럼 열린 질문에 사용하세요. 30초 만에 요청을 끊는 클라이언트라면 Prefer: respond-async 헤더를 붙여 보내세요. 답이 짧다고 자료가 없는 것은 아니니 search/tweets로 다시 확인하세요.
API 레퍼런스 영문 원문
Natural-language search over X (Twitter) powered by xAI's Grok 4.3 model with the built-in x_search tool. Returns a synthesised answer plus X source citations. Pin results to specific authors via from_handles (or exclude with exclude_handles), and narrow to a time window with from_date / to_date. Costs 5 credits per call regardless of how many internal x_search invocations the model performs (see tool_calls_count in the response for visibility). Auto-refunds on upstream failure. Best for freeform questions like 'what is @elonmusk saying about xAI this week' that would otherwise require multiple structured calls to /v1/twitter/profile, /v1/twitter/user/tweets, etc. **Read a thin answer as thin retrieval, never as an empty corpus.** This is a discovery surface: the model runs a handful of internal searches and answers from what they returned, so a reply such as 'limited posts appear on this topic' is a statement about that retrieval, not about X. Keyword search over the same window routinely finds substantially more. A call usually takes 10 to 30 seconds. About a quarter of calls take longer, up to about a minute on broad prompts with several keywords, so set a client timeout of at least 100 seconds. If your client or agent gives up at 30 seconds, send Prefer: respond-async (or add async=true to the query) and poll GET /v1/prism/jobs/{job_id}. As a job, the call costs the same 5 credits and keeps its 90-second budget. If you need the posts rather than a written answer, /v1/twitter/search/tweets lists them in about 2 seconds for 1 credit a page. An identical request repeated within 30 minutes is answered from cache, free, so re-sending the same question more often than that returns the same answer.
75개 플랫폼을 병렬로 검색합니다
AI Search API로 무엇을 할 수 있을까요
AI Search 엔드포인트가 통합 스키마와 계산 필드를 담은 X 데이터를 한 번의 요청으로 보내드려요. 스크래핑 인프라를 직접 만들거나 유지할 필요가 없어요.
요청 예시
# GET /v1/twitter/ai-search: 5 credits per call. Cache hits are free and failed calls are refunded.
# Check the price first for 0 credits: add dry_run=1 to the query. Nothing is fetched or charged.
# --max-time 80: this endpoint's measured p99 latency x 1.5.
# --retry 3: retries timeouts, 429 and 5xx, honoring Retry-After.
# -o response.json keeps only the final attempt's body.
# One Idempotency-Key per request, reused on every retry, so a retried call is never charged twice.
IDEMPOTENCY_KEY=$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')
curl -sS --max-time 80 --retry 3 -o response.json \
-H "x-api-key: YOUR_API_KEY" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
"https://www.socialcrawl.dev/v1/twitter/ai-search?query=What+is+%40elonmusk+saying+about+xAI+this+week%3F" && cat response.json# GET /v1/twitter/ai-search: 5 credits per call. Cache hits are free and failed calls are refunded.
# Check the price first for 0 credits: add dry_run=1 to the query. Nothing is fetched or charged.
import os
import random
import time
import uuid
import requests
API_KEY = os.environ.get("SOCIALCRAWL_API_KEY", "YOUR_API_KEY")
TIMEOUT_S = 80 # this endpoint's measured p99 latency x 1.5.
MAX_RETRIES = 3
URL = "https://www.socialcrawl.dev/v1/twitter/ai-search"
def backoff(attempt):
# Exponential backoff with jitter: about 1 s, 2 s, then 4 s.
return 2 ** attempt * (0.5 + random.random() / 2)
def socialcrawl(params):
# One Idempotency-Key per request, reused on every retry, so a retried call is never charged twice.
idempotency_key = str(uuid.uuid4())
for attempt in range(MAX_RETRIES + 1):
try:
res = requests.get(
URL,
params=params,
headers={"x-api-key": API_KEY, "Idempotency-Key": idempotency_key},
timeout=TIMEOUT_S,
)
body = res.json()
except (requests.RequestException, ValueError):
# A timeout, a dropped connection or a non-JSON gateway page: retry with the same key.
if attempt == MAX_RETRIES:
raise
time.sleep(backoff(attempt))
continue
if body["success"]:
return body
error = body["error"]
# Branch on error["type"], never on the message text.
if error["type"] == "RESOURCE_NOT_FOUND":
return None # refunded: nothing to read
retry_after = res.headers.get("Retry-After")
# SERVICE_UNAVAILABLE without Retry-After is a withdrawn endpoint: permanent.
permanent = error["type"] == "SERVICE_UNAVAILABLE" and retry_after is None
if not error.get("retryable") or permanent or attempt == MAX_RETRIES:
raise RuntimeError(f"{error['type']}: {error['message']} (request_id {body['request_id']})")
# Retry-After (seconds) wins; otherwise back off.
time.sleep(float(retry_after) if retry_after else backoff(attempt))
params = {
"query": "What is @elonmusk saying about xAI this week?",
}
body = socialcrawl(params)
if body is not None:
print(body["data"])// GET /v1/twitter/ai-search: 5 credits per call. Cache hits are free and failed calls are refunded.
// Check the price first for 0 credits: add dry_run=1 to the query. Nothing is fetched or charged.
const API_KEY = process.env.SOCIALCRAWL_API_KEY ?? "YOUR_API_KEY";
const TIMEOUT_MS = 80_000; // this endpoint's measured p99 latency x 1.5.
const MAX_RETRIES = 3;
type Page = { next_cursor: string | null; has_more: boolean };
type SocialCrawlResponse =
| { success: true; data: any; pagination?: Page; credits_used: number; request_id: string }
| { success: false; error: { type: string; message: string; retryable: boolean }; request_id: string };
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
// Exponential backoff with jitter: about 1 s, 2 s, then 4 s.
const backoffMs = (attempt: number) => 2 ** attempt * 1000 * (0.5 + Math.random() / 2);
async function socialcrawl(url: URL) {
// One Idempotency-Key per request, reused on every retry, so a retried call is never charged twice.
const idempotencyKey = crypto.randomUUID();
for (let attempt = 0; ; attempt++) {
let res: Response;
let body: SocialCrawlResponse;
try {
res = await fetch(url, {
headers: {
"x-api-key": API_KEY,
"Idempotency-Key": idempotencyKey,
},
signal: AbortSignal.timeout(TIMEOUT_MS),
});
body = (await res.json()) as SocialCrawlResponse;
} catch (error) {
// A timeout, a dropped connection or a non-JSON gateway page: retry with the same key.
if (attempt >= MAX_RETRIES) throw error;
await sleep(backoffMs(attempt));
continue;
}
if (body.success) return body;
// Branch on error.type, never on the message text.
if (body.error.type === "RESOURCE_NOT_FOUND") return null; // refunded: nothing to read
const retryAfter = res.headers.get("Retry-After");
// SERVICE_UNAVAILABLE without Retry-After is a withdrawn endpoint: permanent.
const permanent = body.error.type === "SERVICE_UNAVAILABLE" && retryAfter === null;
if (!body.error.retryable || permanent || attempt >= MAX_RETRIES) {
throw new Error(`${body.error.type}: ${body.error.message} (request_id ${body.request_id})`);
}
// Retry-After (seconds) wins; otherwise back off.
await sleep(retryAfter ? Number(retryAfter) * 1000 : backoffMs(attempt));
}
}
const url = new URL("https://www.socialcrawl.dev/v1/twitter/ai-search");
url.searchParams.set("query", "What is @elonmusk saying about xAI this week?");
const body = await socialcrawl(url);
if (body) console.log(body.data);파라미터
| 파라미터 | 필수 | 설명 |
|---|---|---|
| query | 예 | Natural-language prompt describing what you want to learn from X. The model autonomously searches X using the x_search tool with any handle / date filters you provide. |
| from_handles | 아니오 | Comma-separated X handles (max 10). Restricts the search to posts from these accounts only. Mutually exclusive with exclude_handles. |
| exclude_handles | 아니오 | Comma-separated X handles (max 10) to exclude from search results. Mutually exclusive with from_handles. |
| from_date | 아니오 | ISO 8601 start date (YYYY-MM-DD). Limits the search window to posts on or after this date. |
| to_date | 아니오 | ISO 8601 end date (YYYY-MM-DD). Limits the search window to posts on or before this date. |
X AI Search API는 무엇을 돌려주나요
이 엔드포인트의 응답 구조와 필드를 보여 주는 예시예요. 값은 이해를 돕기 위한 것이며 실제 조회 결과는 아니에요.
응답 예시 보기
{
"success": true,
"platform": "twitter",
"endpoint": "/v1/twitter/ai-search",
"data": {
"answer": "Elon Musk recently posted about xAI's new reasoning model, highlighting its real-time X search capability...",
"sources": [
{
"url": "https://x.com/user_58cc83/status/1234567890",
"title": "elonmusk on X"
}
],
"tool_calls_count": 1
},
"credits_used": 5,
"credits_remaining": 95,
"request_id": "req-a1b2c3d4e5f6",
"cached": false
}문서에 나온 응답 구조를 보여 주는 예시예요. 값은 이해를 돕기 위한 것이며 운영 환경에서 가져온 응답이 아니에요.
X AI Search API는 어떻게 동작하나요
API 키와 함께 GET 요청을 보내면, 통합 스키마와 계산 필드를 담은 깔끔한 JSON이 돌아와요.
메서드
GET
응답 형식
JSON
소셜 미디어 데이터를 몇 초 만에 수집하는 방법
개발자를 위한 가장 빠른 소셜 미디어 스크래핑 API. 월간 활성 사용자 100억 명 이상을 포괄하는 75개 플랫폼에서 프로필, 게시물, 댓글, 분석 데이터를 수집하세요.
모든 플랫폼을 하나의 스키마로
동일한 응답 구조로 75개 플랫폼을 조회하세요. 연동은 한 번이면 충분합니다.
단순 수집을 넘어 계산된 필드 제공
엔드포인트가 해당 지표를 지원하고 계산에 필요한 원본 값이 있을 때, 정규화된 레코드에 engagement_rate, estimated_reach, content_category, language를 함께 담아 바로 활용할 수 있습니다.
코드 한 줄 쓰기 전에, 데이터부터
Visual Data Explorer에 URL만 붙여넣으면 결과 카드와 정형화된 테이블, CSV 내보내기를 바로 사용할 수 있습니다.
import requests
response = requests.get(
'https://www.socialcrawl.dev/v1/tiktok/profile',
params={'handle': 'charlidamelio'},
headers={'x-api-key': 'sc_YOUR_API_KEY'}
)
data = response.json(){
"success": true,
"platform": "tiktok",
"data": {
"author": {
"username": "charlidamelio",
"followers": 152400000
},
"engagement": {
"likes": 12400000000,
"engagement_rate": 0.087
},
"metadata": {
"language": "en",
"content_category": "lifestyle"
}
}
}자주 묻는 질문
API, 요금제, 기능에 대한 질문과 답변입니다.
문의하기Twitter AI 검색 API는 무엇인가요?
일반 트윗 검색과 뭐가 다른가요?
특정 계정이나 기간으로 좁힐 수 있나요?
어떤 모델로 검색하나요?
Twitter AI 검색 API 요금은 얼마인가요?
AI에게 SocialCrawl을 물어보세요
X AI Search 데이터, 가져올 준비 되셨어요?
API 키 받고 60초 안에 X 데이터를 받아 가세요.
