Harsh Kothari
Harsh Kothari

Reputation: 75

How to solve operator error on Twitter search API 2.0

I have read the full documentation of the new version of Twitter search API 2.0 which is used to implement the Premium search API version. Currently, I am using python to fetch tweets from Twitter and I am using searchtweets library to implement it. I have set up the free tier of premium search API in my developer portal.

Problem - When I try to fetch tweets based on $CASHTAGS like $AMZN it says $CASHTAGS are not allowed to use but according to the documentation I can use $CASHTAGS filtering.

My code -

account_type = 'premium'
endpoint = 'https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'

from searchtweets import gen_rule_payload 
from searchtweets import ResultStream

query = '($AMZN)'
rule = gen_rule_payload(query, results_per_call=100, from_date="2021-02-01", to_date="2021-02-10")

rs = ResultStream(rule_payload=rule,
                  max_results=3000,
                  **premium_search_args)

for tweet in rs.stream():
        print(tweet)

Error -

HTTP Error code: 422: {"error":{"message":"There were errors processing your request: 
Reference to invalid operator 'cashtag'. Operator is not available in current product or product packaging.}}

Upvotes: 0

Views: 1296

Answers (1)

Philippe Ostiguy
Philippe Ostiguy

Reputation: 61

According to your endpoint, you are using Twitter API 1.1 endpoint='https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'.

If you refer to Twitter API version 2.0, as of June 1st 2021, cashtags are available only for the academic research product track.

See link : https://twittercommunity.com/t/reference-to-invalid-operator-cashtag-operator-is-not-available-in-current-product-or-product-packaging/141990/7

Upvotes: 2

Related Questions