Trouble Getting Started with Premium Search API


I’m having a bit of trouble getting started with the Premium Search API. I’ve made an environment, installed cURL, and retrieved my Bearer token. But I can’t figure out how to retrieve counts data.

When I enter in the following code (using my actual token)…

curl --request POST
–header ‘authorization: Bearer TOKEN’
–header ‘content-type: application/json’
–data ‘{
"query”:”brecht AND trump AND (dark times)”,
“bucket”: “month”

I get this error: {“error”:{“message”:“Invalid json, could not parse.”,“sent”:“2019-02-20T21:21:50+00:00”,“transactionId”:“00c36b7d002e6b25”}}

Or when I use this query…

curl -X POST “” -d '{“query”:”(brecht AND trump AND (dark times))”,”fromDate”:"<201501010000>",“toDate”:"<201902150000>","bucket”:”month”}’ -H “Authorization: Bearer TOKEN”

… it just goes to the next line. How do I retrieve my data? Thanks!


It’s possible, but significantly more complicated to use just plain curl for this. (In your call i think the issue might be the extra < and > in the dates)

It might be easier to use the command line tool from:

Once installed, you can run

python \
--credential-file twitter_keys.yaml \
--max-results 100 \
--results-per-call 100 \
--filter-rule "(brecht AND trump AND (dark times))" \
--start-datetime 2015-01-01 \
--end-datetime 2019-01-01 \
--filename-prefix test_search \

Running that assumes you have python 3 installed, and there is a twitter_keys.yaml file in the directory (like the github readme describes). It will save a test_search.json file with results.

closed #3

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