Tweet search workflow to JSON Lines, CSV, or XLSX
Export tweet search from Java services, Spring Batch, scheduled workers, or queues. Save files for data lakes, CRM enrichment, CSV, XLSX, or downstream processing.client.x().tweets().search calls GET /x/tweets/search. Build TweetSearchParams with the REST query parameters .q(), .limit(), .cursor(), .sinceTime(), .untilTime(), and .queryType().Request mapping
.q()
Java builder method
.q() maps to REST q. Use it for an X (Twitter) search query. Examples are from:username, a keyword, hashtag, or boolean operator query..limit()
Java builder method
.limit() maps to REST limit. Use it as a 1 to 200 upper bound for a bounded pull. If page.hasNextPage() is true, keep the same .q(), filters, .queryType(), and .limit(). Do so when you continue with page.nextCursor()..cursor()
Java builder method
.cursor() maps to REST cursor. Pass the opaque cursor from page.nextCursor() to request the next page..sinceTime()
Java builder method
.sinceTime() maps to REST sinceTime. Use it as the ISO 8601 lower bound for tweet creation time..untilTime()
Java builder method
.untilTime() maps to REST untilTime. Use it as the ISO 8601 upper bound for tweet creation time..queryType()
Java builder method
.queryType() maps to REST queryType. Use QueryType.LATEST for chronological search or QueryType.TOP for engagement-ranked search.Returned data & handoff
client.x().tweets().search returns PaginatedTweets. Use page.tweets() for the tweet list. Use page.hasNextPage() to decide whether another page exists. Use page.nextCursor() as the checkpoint for the next request. For bounded pulls that return fewer tweets than the requested .limit(), resume from page.nextCursor(). To do that, pass page.nextCursor() back as .cursor(). Send the same query, filters, QueryType, and .limit() with that cursor.Each SearchTweet includes generated accessors such as id(), text(), author(), and createdAt(). Others are likeCount(), replyCount(), retweetCount(), quoteCount(), viewCount(), and bookmarkCount(). It also includes isNoteTweet() when available. Project page.tweets() into JSON Lines and CSV rows with tweet_id, author_username, and engagement counts. Rows also carry page_index, page_cursor, next_cursor, and has_next_page. Workers can then resume. They can also load the same records into XLSX, CRM, warehouse, or agent workflows.Tweet search costs 1 credit per tweet returned. Remaining credits may not cover a bounded .limit() request. If so, the API can return fewer tweets. If 0 paid results are affordable, it returns 402 insufficient_credits. The SDK supports withOptions() for retry and request settings. For explicit .limit() pulls, resume with the same query, filters, QueryType, and .limit(). Only .cursor() changes.