I have a certain Twitter topic (and its id) that I want to pull the recent tweets of ..
I know the topic of a certain tweet is stored in its “context_annotations” attribute.
Is there a way in Twitter API to pull tweets of a certain topic, similar to how we pull tweets of certain keywords or hashtags?
I have looked in the search query and twitter api v2 and seem to have found nothing in that matter ..
Yes, use:
https://api.twitter.com/2/tweets/search/recent?query=context%3A<domain_id>.<entity_id>
The Twitter API allows for searching by a domain ID / entity ID pair using the context:
operator. (Searching using only a domain ID is not supported.) This functionality is described further in this documentation page under the section "Find Tweets that relate to a specific Tweet annotation".
For example, if you wanted to find tweets related to domain 66
(Interests and Hobbies) and entity ID 852262932607926273
(Cats), you'd use:
https://api.twitter.com/2/tweets/search/recent?query=context%3A66.852262932607926273