skip to Main Content

I want to fetch all tweets based on a hashtag but I only want to fetch tweets that have media In the documentation there is no specification regarding query only if there is media in the tweet, for example, something like media: true can this be done in the query?

client.search("#technology", { tweet_mode: "extended", include_entities: true, fromDate:"201801071200",toDate:"201802071200", entities: true})

Is I add media: true would that work ? and if not how to go about only fetching if there is media on the tweet

2

Answers


  1. I guess filter:media is the correct operator.

    something like

    client.search("#technology filter:media", { tweet_mode: "extended", include_entities: true, fromDate:"201801071200",toDate:"201802071200", entities: true})
    

    Here is the reference: https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators. Hope, that helps.

    If you are searching with Premium search APIs then operator changes to has:media: https://developer.twitter.com/en/docs/tweets/search/guides/premium-operators

    Overview: https://developer.twitter.com/en/docs/tweets/search/overview

    Login or Signup to reply.
  2. If I am not wrong, there is a filter has:media which can be used to retrieve tweets that have an attached media. But it is only available to premium and enterprise operators.

    Here is the reference

    https://developer.twitter.com/en/docs/tweets/search/guides/premium-operators

    Otherwise you can always fetch tweets and filter the ones which have media by fetching tweets with extended entities. From the entities property you can check if the media property is available and has values. If it does, you know you have a tweet with media.

    Login or Signup to reply.
Please signup or login to give your own answer.

I want to fetch all tweets based on a hashtag but I only want to fetch tweets that have media In the documentation there is no specification regarding query only if there is media in the tweet, for example, something like media: true can this be done in the query?

client.search("#technology", { tweet_mode: "extended", include_entities: true, fromDate:"201801071200",toDate:"201802071200", entities: true})

Is I add media: true would that work ? and if not how to go about only fetching if there is media on the tweet

2

Answers


  1. I guess filter:media is the correct operator.

    something like

    client.search("#technology filter:media", { tweet_mode: "extended", include_entities: true, fromDate:"201801071200",toDate:"201802071200", entities: true})
    

    Here is the reference: https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators. Hope, that helps.

    If you are searching with Premium search APIs then operator changes to has:media: https://developer.twitter.com/en/docs/tweets/search/guides/premium-operators

    Overview: https://developer.twitter.com/en/docs/tweets/search/overview

    Login or Signup to reply.
  2. If I am not wrong, there is a filter has:media which can be used to retrieve tweets that have an attached media. But it is only available to premium and enterprise operators.

    Here is the reference

    https://developer.twitter.com/en/docs/tweets/search/guides/premium-operators

    Otherwise you can always fetch tweets and filter the ones which have media by fetching tweets with extended entities. From the entities property you can check if the media property is available and has values. If it does, you know you have a tweet with media.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search