Skip to main content
This guide builds on the Go SDK setup, which covers install and authentication.

Tweet search workflow to JSON Lines, CSV, or XLSX

Search newest tweets with client.X.Tweets.Search through GET /x/tweets/search. Write each tweet as a JSON line for queues, data lakes, CSV, or XLSX.
The example builds an XTweetSearchParams request so the Go fields stay aligned with GET /x/tweets/search. The generated params map directly to the REST endpoint.

Q

Go field Q maps to REST q. It holds the required X (Twitter) search query with keywords, handles, hashtags, or operators.

Limit

Go field 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

Go field Cursor maps to REST cursor. Pass the opaque cursor from NextCursor to request the next page.

SinceTime

Go field SinceTime maps to REST sinceTime. Use the inclusive ISO bound on every page.

UntilTime

Go field UntilTime maps to REST untilTime. Use the exclusive ISO bound on every page.

QueryType

Go field QueryType maps to REST queryType. Use Latest for chronological results or Top for engagement-ranked results.

Returned data & handoff

client.X.Tweets.Search returns PaginatedTweets.

Tweets

JSON field tweets. Contains tweet records with ID, Text, Author, and CreatedAt. Records also carry LikeCount, ReplyCount, RetweetCount, QuoteCount, BookmarkCount, ViewCount, and IsNoteTweet when available.

HasNextPage

Go field HasNextPage. JSON field has_next_page. Tells your worker whether another page exists.

NextCursor

JSON field next_cursor. Store it only when page.HasNextPage is true. For bounded pulls that return fewer tweets than Limit, pass it back as Cursor. Send the same query, filters, QueryType, and Limit with that cursor.
Write Tweets as JSON Lines to xquik-tweet-search.jsonl for queues and data lakes. Transform the projected records into CSV for analysts. When account teams need spreadsheets, produce XLSX from those rows. Pass ID, Text, Author.Username, CreatedAt, and engagement counts into your CRM or enrichment pipeline. For explicit Limit pulls, resume with the same query, filters, QueryType, and Limit. Only Cursor changes.

Next steps