I’ve just got access to the Premium API (Sandbox) and I’m learning how to use it. I followed the steps in https://twitterdev.github.io/search-tweets-python/index.html but I’m getting the following error: “HTTP Error code: 422: Unprocessable Entity: This is returned due to invalid parameters in a query or when a query is too complex for us to process. –e.g. invalid PowerTrack rules or too many phrase operators, rendering a query too complex.”
The query I’m testing is simply: “#vaccines”. I’m testing the full archive sandbox (I labeled the environment “Crawling”) and here are all the code lines I used:
from searchtweets import ResultStream, gen_rule_payload, load_credentials import os os.environ["SEARCHTWEETS_ACCOUNT_TYPE"] = "premium" os.environ["SEARCHTWEETS_ENDPOINT"] = "https://api.twitter.com/1.1/tweets/search/fullarchive/Crawling.json" os.environ["SEARCHTWEETS_CONSUMER_KEY"] = "<key>" os.environ["SEARCHTWEETS_CONSUMER_SECRET"] = "<secret>" premium_search_args = load_credentials("",yaml_key="") rule=gen_rule_payload(pt_rule="#vaccine") rs = ResultStream(rule_payload=rule,max_results=30,max_pages=1,**premium_search_args) tweets = list(rs.stream())
I’m not sure if the problem is in the query itself or the setup of my authentication (for example the endpoint url?). Appreciate any answer.