Adding search operators to TwitterAPI (Premium Search)



I am using the TwitterAPI library in Python with the 30 day Premium API (Sandbox mode). Everything works until I try to add more search operators such as ‘maxResults’ : ‘500’. Whenever I add a new operator I get a 422 error. What is the right way to use these operators in a query? I have tried adapting the example given in the Twitter Documentation for ‘Example POST Request’ (, but nothing seems to work.

My code is as follows:

from TwitterAPI import TwitterAPI

SEARCH_TERM = ‘#Dáil100 OR #soloheadbeg lang:en’
PRODUCT = ‘30day’
LABEL = ‘dev’

api = TwitterAPI("XXXX",

r = api.request('tweets/search/%s/:%s' % (PRODUCT, LABEL),
                   {'query': SEARCH_TERM, "maxResults":"500"})

for item in r:
    print(item[‘text’] if ‘text’ in item else item)


That looks ok, except maxResults is limited to 100 in Sandbox mode


(Also, in case you’re not doing it already: To save on calls, It’s worth using the Standard API Search to get the last 7 days of tweets, and Fullarchive search for >30 days ago for the Dail100 Tweets in January)


Thank you this worked - figured it must be something really simple that I was just not seeing anymore! And yes been using standard API up til now but using the 30day sandbox to test out for using fullarchive eventually.