Get all tweets with specific hashtag

Oct 29, 2013 at 2:09 PM

Reading through the documentation and code...
What is the best way to search for all tweets with a specific hashtag?
Oct 29, 2013 at 2:18 PM
Hi there,

I need a bit more details concerning what you mean by search :
  • Search from the Tweets posted by a specific User
  • Search from all the Tweets published online
  • Get all the Tweets in live that contains a specific hashtag
Oct 29, 2013 at 3:01 PM
Sorry for such a vague question.

Ideally to search for tweets with a specific hashtag.

I saw the SearchUser example in Examplinvi but I would like to seach by hashtag for all users.

Is that possible?

Oct 29, 2013 at 4:20 PM
Edited Oct 29, 2013 at 4:22 PM

Thanks for the response.

Is that possible?

Is it implemented?

How to do then!?
This is one of the function provided by Twitter REST API 1.1 that has not yet been implemented.
I am currently working hard on implementing a new architecture for Tweetinvi so I will not have time to implement this method for you in the near future.
Though Tweetinvi has been developed so that it is very easy for developers to implement their own methods.

The only thing you have to do understand how to create your query.
Go on Twitter Documentation page for Search Tweets and find how you will construct your query (a string)
Example to search the hashtag '#freebananas' :

Here is a very simple solution to search tweets with a specific Hashtag :
private static List<ITweet> GetListOfTweetsWithHashTag(string hashTag, IToken token)
    string searchQuery = String.Format("{0}", hashTag);

    List<ITweet> tweets = new List<ITweet>();

    ObjectResponseDelegate responseDelegate = responseObject =>
        var matchingTweets = responseObject.GetPropCollection<Dictionary<string, object>>("statuses");
        foreach (var matchingTweet in matchingTweets)
            tweets.Add(new Tweet(matchingTweet));

    token.ExecuteGETQuery(searchQuery, responseDelegate);

    return tweets;

// Call it
var matchingTweets = GetListOfTweetsWithHashTag("tweetinvi", token);
I leave you improve this code to match your requirements :)
Please let me know if this solves your problem.

Kind Regards,
Marked as answer by linvi on 10/29/2013 at 12:53 PM
Oct 29, 2013 at 6:03 PM
Thanks for your speedy reply and assistance.

Unfortunately GetPropCollection is undefined and I can't work out why GRRR!
Oct 29, 2013 at 6:23 PM
Edited Oct 29, 2013 at 6:23 PM
Please verify that you have referenced Tweetincore and that you have the following using:
using TweetinCore.Extensions;
Oct 29, 2013 at 8:29 PM
Fantastic! That was the correct answer.
Thanks for you help and keep up the great work.
Dec 11, 2013 at 11:34 AM
Hi Linvi,

You have created a great library here so thank you, however i have used your suggested workaround for the tweet search however i am getting a 401 Unauthorized response for my token, any idea's whats happening here?


Dec 11, 2013 at 11:41 AM
Edited Dec 11, 2013 at 11:42 AM
Hi Scott,

Usually a 401 exception means that you the credentials you provided are incorrect. First please verify that the credential you provided are in the correct order.
If you are running your application in debug mode, you can access the Console and read query sent to twitter to perform the query.
At this point please verify that the credentials are correct in the console.

If this does not solve your problem, please contact me by the contact form so that we can analyze your specific problem.

Dec 20, 2013 at 12:07 AM
Try changing your access level ( to "Read/Write/DirectMessages" and recreate your token.
Jan 2, 2014 at 11:56 AM
What we need to send in token ? In this line GetListOfTweetsWithHashTag("tweetinvi", token);
May 15, 2014 at 6:55 PM
Hi Linvi,

A newbie here to twitter.

Two questions, if you have the time;
  1. How do I create the "token" as I cannot seem to find IToken. Is there a method I can use to generate it?
  2. When will you support searching using Hash Tags?
Many thanks
May 17, 2014 at 2:13 AM
Edited May 17, 2014 at 2:14 AM

Tokens are not used anymore. Just set your credentials as described in the documentation tab.
The example of this post is out of date.
TwitterCredentials.SetCredentials("Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret");
Jan 15, 2015 at 8:28 PM
Hi Linvi,

Can you provide a new example that works with the 0.9.5 and Twitter new Security policy of TLS.

Mohit Chhabra
Feb 16, 2015 at 7:16 AM
Edited Feb 16, 2015 at 7:19 AM
Hi Linvi,

Is this the same method to Get all the Tweets in live that contains a specific hashtag ?
If Not can u guide me?
I want to search all the tweet with a specific hashtag provided by the user from textbox.