How to use the 'from:' operator with Premium API?

Hi everyone. I’m doing an exams project on tweets from Donald Trump. But when I write:

I receive an empty JSON object. What’s wrong? It is his user id, and from what I’ve read I should exclude the ‘@’ from the user name. I read about it here:
Best regards Christina

Thanks for getting in touch. Do you have a more complete code snippet that we can take a look at here?
Also, if you are just getting started you might want to check out the search tweets wrapper for Python or Ruby if you haven’t already.

I’m using Python 3 for the search. Thanks for the link the Python library. For this school project I have to use just the API’s own code and no libraries though. Here is my code:

def apiTrump(antal_requests):
    import os, json
    global trump_count
    global sundays
    request_count = 0
    while request_count < antal_requests:
        data = '{"query":"from:realDonaldTrump", "maxResults": 500, "fromDate": "201605051415", "toDate": "' + sundays[trump_count] + '"}'
        resp =,data=data,headers=headers)
        response = resp.json()
        with open('Trump\Trump' + str(trump_count) + '.json', 'w') as data_fil: 
        request_count += 1      
        trump_count +=1```

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.