Celine Suarez
Celine Suarez

Reputation: 11

How can I query keywords within a user's timeline using Twitter's API v1.1?

I've searched all over and even tried using the dev console for Twitter, but I can't find a way to search for certain keywords within a user's timeline. At first, I attempted to use the GET search/tweets as listed here:

https://dev.twitter.com/rest/reference/get/search/tweets

But there's no parameter to enter in a username. I attempted adding a custom parameter using from as the name and my own twitter handle as the value. It wouldn't limit the tweets to my own, so then I attempted to use the GET statuses/user_timeline as listed here:

https://dev.twitter.com/rest/reference/get/statuses/user_timeline

There is no 'q' parameter so I attempted adding it as a custom parameter with q as the name and a random word as a value. All of my tweets still came up. I've been working with the apigee Twitter dev console testing all of this out. Has anyone come across a workaround?

Upvotes: 0

Views: 1119

Answers (2)

b4tch
b4tch

Reputation: 1198

I realise this is old but I needed the same thing. As per the Twitter docs, it now states the following format URL can be used (in this example, to get all tweets from @Cmdr_Hadfield with the hashtag #nasa):

https://api.twitter.com/1.1/search/tweets.json?q=from%3ACmdr_Hadfield+%23nasa

The results can be verified by using the twitter.com search:

https://twitter.com/search/?q=from%3ACmdr_Hadfield%20%23nasa

Upvotes: 1

Celine Suarez
Celine Suarez

Reputation: 11

Turns out there's no way to combine the two resources in one call. Looks like this has been requested from Twitter a few times but there's not a way to add custom parameters to a different resource.

Upvotes: 1

Related Questions