geduldig / TwitterAPI

Minimal python wrapper for Twitter's REST and Streaming APIs
939 stars 263 forks source link

AND operator in Twitter API Premium #135

Closed ardiantovn closed 4 years ago

ardiantovn commented 4 years ago

I tried two queries using Twitter fullarchive Premium API sandbox version:

  1. 'corona OR masker'
  2. 'corona AND masker' Query number 2 returns error 422. Why only query number 1 is successful? How to use the AND operator correctly? Thank You
geduldig commented 4 years ago

AND is not an operator. For number 2, do this instead: 'corona masker'.

ardiantovn commented 4 years ago

Ok. I want to get tweets containing the word corona and masker. How to write this query correctly?

geduldig commented 4 years ago

Do this: 'corona masker'.

ardiantovn commented 4 years ago

I'm sorry, I didn't pay attention to your answer before. I am sorry...

I want to ask another similar thing, for example I want to get a tweet about Corona. I want to make sure that the tweet contains these words: (mask, hand sanitizer, or donation).

I can get the results I expect at www.twitter.com/search by writing like this: corona AND (masker OR "hand sanitizer" OR donation).

I can't write a query like that on the Twitter API because AND is not an operator. Then, do I have to write on the Twitter API like this to get the results I want? corona masker "hand sanitizer" donation

Thank you

geduldig commented 4 years ago

corona (masker OR "hand sanitizer" OR donation)

ardiantovn commented 4 years ago

Thank you very much for the answer...

geduldig commented 4 years ago

You are welcome!