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

Tweet search workflow to JSON Lines, CSV, or XLSX

This workflow is for a .NET worker, console job, or ASP.NET background service. Use it when that code needs tweet search results in a durable handoff format. The handoff can go to a queue, data lake, or analyst CSV export. It can also go to an XLSX workbook or CRM enrichment step. client.X.Tweets.Search calls GET /x/tweets/search. Build a TweetSearchParams object with the same query parameters the REST API accepts. They are Q, Limit, Cursor, SinceTime, UntilTime, and QueryType.

Request mapping

Q

C# property 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

C# property 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

C# property Cursor maps to REST cursor. Pass the opaque cursor from page.NextCursor to request the next page.

SinceTime

C# property SinceTime maps to REST sinceTime. Use it as the ISO 8601 lower bound for tweet creation time.

UntilTime

C# property UntilTime maps to REST untilTime. Use it as the ISO 8601 upper bound for tweet creation time.

QueryType

C# property 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 array. 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 Limit, pass page.NextCursor back as Cursor. Send the same query, filters, QueryType, and Limit with that cursor.Each SearchTweet includes typed properties 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 retries connection errors, 408, 409, 429, and 5xx responses. It does so 2 times by default. For explicit Limit pulls, resume with the same query, filters, QueryType, and Limit. Only Cursor changes.

Next steps