title: How can I retrieve all the tweets from a keyword using Tweetinvi?
body: <p>I am a new C# developer and I am trying to develop an ASP.NET Webforms application to search Twitter using Tweetinvi library. I was able to search Twitter by user and phrase. However, I am struggling now with searching the tweets by phrase as it only returns a small number of tweets that is below 150 tweets and I don't know why. </p>
  
  <p>I was able to retrieve more than 1700 tweets by user, but i could only get 150 tweets when I applied the same concept of code on search by phrase and I don't know why. </p>
  
  <p><strong><em>Kindly note that the phrase in Searching Tweets by Phrase could be any keyword, hashtag or twitter account name</em></strong></p>
  
  <p>Here's the C# code for searching the tweets by phrase:</p>
  
  <pre><code>private List&lt;ITweet&gt; GetFilteredTweets(string keyword)
          {
              try
              {
                  RateLimit.RateLimitTrackerMode = RateLimitTrackerMode.TrackAndAwait;
  
                  RateLimit.QueryAwaitingForRateLimit += (se, ar) =&gt;
                  {
                      Console.WriteLine($"Query : {ar.Query} is awaiting for rate limits!");
                  };
  
                  // Create a parameter for queries with specific parameters
                  var searchParameters = new SearchTweetsParameters(keyword)
                  {
                      Lang = LanguageFilter.English,
                      SearchType = SearchResultType.Mixed,
                      //MaximumNumberOfResults = 100,
                      MaximumNumberOfResults = 200,
                      TweetSearchType = TweetSearchType.OriginalTweetsOnly
                  };
  
                  var lastTweets = Tweetinvi.Search.SearchTweets(searchParameters).ToArray();
  
                  var allTweets = new List&lt;ITweet&gt;(lastTweets);
                  var beforeLast = allTweets;
  
                  while (lastTweets.Length &gt; 0 &amp;&amp; allTweets.Count &lt;= 3200)
                  {
                      var idOfOldestTweet = lastTweets.Select(x =&gt; x.Id).Min();
                      Console.WriteLine($"Oldest Tweet Id = {idOfOldestTweet}");
  
                      var numberOfTweetsToRetrieve = allTweets.Count &gt; 3000 ? 3200 - allTweets.Count : 200;
                      var searchRequestParameters = new SearchTweetsParameters(keyword)
                      {
                          Lang = LanguageFilter.English,
                          SearchType = SearchResultType.Mixed,
                          // MaxId ensures that we only get tweets that have been posted 
                          // BEFORE the oldest tweet we received
                          MaxId = idOfOldestTweet - 1,
                          MaximumNumberOfResults = numberOfTweetsToRetrieve,
                          TweetSearchType = TweetSearchType.OriginalTweetsOnly
                      };
  
                      lastTweets = Tweetinvi.Search.SearchTweets(searchRequestParameters).ToArray();
                      allTweets.AddRange(lastTweets);
                  }
                  // `allTweets` now contains all the tweets that Twitter can return
                  tweetList = allTweets;
                  return allTweets;
              }
              catch (Exception ex)
              {
                  throw ex;
              }
          }
  </code></pre>