Skip to main content
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.
Full-archive search requires Self-serve or Enterprise access. Upgrade your access to use this endpoint.
PrerequisitesBefore you begin, you’ll need:
  • A developer account
  • Your App’s Bearer Token (found in the Developer Console under “Keys and tokens”)

Step 1: Build a query

Full-archive search supports all query operators. Build queries the same way as recent search:
from:XDevelopers lang:en
Full-archive search supports queries up to 1,024 characters (4,096 for Enterprise).

Step 2: Set a time range

By default, results return Posts from the last 30 days. Use start_time and end_time to search specific periods:
ParameterFormatExample
start_timeISO 86012020-01-01T00:00:00Z
end_timeISO 86012020-12-31T23:59:59Z

Step 3: Make a request

cURL
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"
from xdk import Client

client = Client(bearer_token="YOUR_BEARER_TOKEN")

# Full-archive search with pagination
for 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 pagination
const 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);
  });
}

Step 4: Review the response

{
  "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.

Step 5: Add fields and expansions

Request additional data with query parameters:
cURL
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"
from xdk import Client

client = Client(bearer_token="YOUR_BEARER_TOKEN")

# Search with fields and expansions
for 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]}...")
import { Client } from "@xdevplatform/xdk";

const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

// Search with fields and expansions
const paginator = client.posts.searchAll({
  query: "from:XDevelopers",
  startTime: "2020-01-01T00:00:00Z",
  endTime: "2020-12-31T23:59:59Z",
  tweetFields: ["created_at", "public_metrics", "author_id"],
  expansions: ["author_id"],
  userFields: ["username", "description"],
  maxResults: 100,
});

for await (const page of paginator) {
  page.data?.forEach((post) => {
    console.log(`${post.created_at}: ${post.text?.slice(0, 50)}...`);
  });
}

Step 6: Paginate through results

The SDKs handle pagination automatically. For cURL, use the next_token from the response:
curl "https://api.x.com/2/tweets/search/all?\
query=from%3AXDevelopers&\
max_results=500&\
next_token=b26v89c19zqg8o3fo7gesq314yb9l2l4ptqy" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Pagination guide

Learn more about navigating large result sets

FeatureRecent SearchFull-Archive Search
Time rangeLast 7 daysMarch 2006 to now
Access requiredAll developersPay-per-use, Enterprise
Max results per request100500
Query length512 chars1,024 chars
Rate limit450 / 15 min300 / 15 min, 1 / sec
AuthenticationApp-Only, User ContextApp-Only

Common parameters

ParameterDescriptionDefault
querySearch query (required)
max_resultsPosts per page (10-500)10
start_timeOldest Post timestamp30 days ago
end_timeNewest Post timestampNow
next_tokenPagination token
tweet.fieldsAdditional Post fieldsid, text
expansionsRelated objects to include

Next steps

Build a query

Master query syntax and operators

Operator reference

See all available operators

Pagination guide

Handle large result sets

API Reference

Full endpoint documentation