Reputation: 1114
Is there any way to count how many people tweeted to me and included a certain hashtag and have a breakdown by user, for instance,
etc.
Upvotes: 0
Views: 24
Reputation:
You can use the premium search APIs to do this, using the counts endpoint. Both the 30-day and full archive search APIs support counts, at the paid premium tier (not available in the free sandbox).
You'd make a query similar to this one, to get back a time series of counts data.
{
"query": "to:andypiper from:userA #certainhashtag",
"bucket": "day"
}
The results look something like this (for a 30-day search request):
{
"results": [
{
"timePeriod": "201809040000",
"count": 2
},
{
"timePeriod": "201809030000",
"count": 0
},
{
"timePeriod": "201809020000",
"count": 0
},
{
"timePeriod": "201809010000",
"count": 0
},
{
"timePeriod": "201808310000",
"count": 0
},
{
"timePeriod": "201808300000",
"count": 0
},
{
"timePeriod": "201808290000",
"count": 0
},
{
"timePeriod": "201808280000",
"count": 0
},
{
"timePeriod": "201808270000",
"count": 0
},
{
"timePeriod": "201808260000",
"count": 0
},
{
"timePeriod": "201808250000",
"count": 0
},
{
"timePeriod": "201808240000",
"count": 0
},
{
"timePeriod": "201808230000",
"count": 0
},
{
"timePeriod": "201808220000",
"count": 0
},
{
"timePeriod": "201808210000",
"count": 0
},
{
"timePeriod": "201808200000",
"count": 0
},
{
"timePeriod": "201808190000",
"count": 0
},
{
"timePeriod": "201808180000",
"count": 0
},
{
"timePeriod": "201808170000",
"count": 0
},
{
"timePeriod": "201808160000",
"count": 0
},
{
"timePeriod": "201808150000",
"count": 0
},
{
"timePeriod": "201808140000",
"count": 0
},
{
"timePeriod": "201808130000",
"count": 0
},
{
"timePeriod": "201808120000",
"count": 0
},
{
"timePeriod": "201808110000",
"count": 0
},
{
"timePeriod": "201808100000",
"count": 0
},
{
"timePeriod": "201808090000",
"count": 0
},
{
"timePeriod": "201808080000",
"count": 0
},
{
"timePeriod": "201808070000",
"count": 0
},
{
"timePeriod": "201808060000",
"count": 0
},
{
"timePeriod": "201808050000",
"count": 0
}
],
"totalCount": 2,
"requestParameters": {
"bucket": "day",
"fromDate": "201808050000",
"toDate": "201809041241"
}
}
Then you simply need to total the counts.
Upvotes: 0
Reputation: 3148
You could use the search API (https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html) with the q parameter with @you #certainhashtag
.
So here you have tweets mentionning you and containing your hashtag.
You can write them to a CSV file. To perform the counts, on a linux system, you will achieve it with a few commands like : awk, cut, grep, wc, uniq...
Or when getting tweets you can code a filter like this :
Upvotes: 2