This guide walks you through making your first full-archive search request to find Posts from. Reference for the Enterprise X API tier covering quickstart.
This guide walks you through making your first full-archive search request to find Posts from the complete X archive, dating back to March 2006.
from xdk import Clientclient = Client(bearer_token="YOUR_BEARER_TOKEN")# Full-archive search with paginationfor page in client.posts.search_all( query="from:XDevelopers", start_time="2020-01-01T00:00:00Z", end_time="2020-12-31T23:59:59Z", max_results=100): for post in page.data: print(post.text)
import { Client } from "@xdevplatform/xdk";const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });// Full-archive search with paginationconst paginator = client.posts.searchAll({ query: "from:XDevelopers", startTime: "2020-01-01T00:00:00Z", endTime: "2020-12-31T23:59:59Z", maxResults: 100,});for await (const page of paginator) { page.data?.forEach((post) => { console.log(post.text); });}
{ "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 }}
Posts created before the edit feature was introduced (September 2022) won’t include edit_history_tweet_ids.
from xdk import Clientclient = Client(bearer_token="YOUR_BEARER_TOKEN")# Search with fields and expansionsfor page in client.posts.search_all( query="from:XDevelopers", start_time="2020-01-01T00:00:00Z", end_time="2020-12-31T23:59:59Z", tweet_fields=["created_at", "public_metrics", "author_id"], expansions=["author_id"], user_fields=["username", "description"], max_results=100): for post in page.data: print(f"{post.created_at}: {post.text[:50]}...")