Tweet search workflow to JSON Lines, CSV, or XLSX
Export tweet search from Kotlin services, scheduled workers, queues, or agents. 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()
Kotlin 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()
Kotlin 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(). Then continue with page.nextCursor()..cursor()
Kotlin builder method
.cursor() maps to REST cursor. Pass the opaque cursor from page.nextCursor() to request the next page..sinceTime()
Kotlin builder method
.sinceTime() maps to REST sinceTime. Use it as the ISO 8601 lower bound for tweet creation time..untilTime()
Kotlin builder method
.untilTime() maps to REST untilTime. Use it as the ISO 8601 upper bound for tweet creation time..queryType()
Kotlin 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(), keep paging. Then pass page.nextCursor() back as .cursor() with the same query, filters, QueryType, and .limit().Each SearchTweet includes generated accessors such as id(), text(), author(), and createdAt(). It also has likeCount(), replyCount(), retweetCount(), quoteCount(), viewCount(), bookmarkCount(), and isNoteTweet() when available. Project page.tweets() into JSON Lines and CSV rows. Rows carry tweet_id, author_username, engagement counts, page_index, page_cursor, next_cursor, and has_next_page. Workers can then resume or load the same records. They can load them 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.