I want to buy a Twitter Premium API to get access to full archive data. I am aware of the packages available as per this link https://developer.twitter.com/en/pricing/search-fullarchive
I want to understand the following,
- How many users data can I collect in one single request?
- How to set the options to limit the time period of collection?
- What will be the format of data received? What columns or fields will I get access to?
- How many queries per request can I make? Will it possible to use advance query options with premium API?
I look forward to hearing from someone. This questions are important to understand before I get the Premium version.
How many users data can I collect in one single request?
The limits are not based on users, the limits are based on a number of requests to the API. Each request is a successful HTTP request, so it can return a maximum of 30 days worth of tweets, or 500 tweets (or 100 tweets in sandbox). Pagination involves making multiple requests.
If you want tweets from a number of users, you have to specify that in the query, using "from:user1 OR from:user2 OR from:user3 ..." and this is limited to 1,024 characters, so if you have a longer query with more users youâll have to split this up into separate requests.
How to set the options to limit the time period of collection?
The time ranges are not set in the query, but in the request parameters - fromDate and toDate https://developer.twitter.com/en/docs/twitter-api/premium/search-api/api-reference/premium-search#DataEndpoint
What will be the format of data received? What columns or fields will I get access to
It will be in v1.1 âCompatibility with additional extended_tweet in payloadâ format, https://web.archive.org/web/20190614005337/https://developer.twitter.com/en/docs/tweets/tweet-updates
(i donât know why they got rid of this documentation page, itâs still relevant, gonna cc @andypiper here for docs change)
How many queries per request can I make? Will it possible to use advance query options with premium API?
Itâs always 1 query per request, but the query you specify can have up to 1024 characters using a mix of all the available operators: https://developer.twitter.com/en/docs/twitter-api/enterprise/rules-and-filtering/operators-by-product and things like brackets, OR, etc: https://developer.twitter.com/en/docs/twitter-api/premium/rules-and-filtering/using-premium-operators
FWIW, that documentation is still available on GitHub ->
Taking onboard that this page could also be restored (or improved and made more relevant to the âin-betweenâ stage that we are at with the API). Thanks.
1 Like
Thank You @IgorBrigadir.
I will go through the links you have shared. If I have any doubts I will reach out to you.
Hi @IgorBrigadir,
I have few more questions I am unable to find answers, please help me here
-
How to write query for specific number of entries without reiterating over next token (like get a whole batch together)?
-
Will each result in JSON format contain tweet id in it?
-
I found a query for getting a tweets from a specifies user.
GET https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2
Can we add fromDate and toDate parameter in this query?
How to write it for multiple users?
Follow https://developer.twitter.com/en/docs/twitter-api/premium/rules-and-filtering/using-premium-operators for how to build a query. You would chain together all your users like this:
from:user1 OR from:user2 OR from:user3
If you have too many for one request you will have to split them up yourself.
Each request gets you 100 tweets in sandbox or 500 on a paid premium plan, or 30 days worth of tweets, which ever is first. There is no way to get a larger batch.
Will each result in JSON format contain tweet id in it?
Yes, you get tweets as an array in the response, and each tweet has the full tweet data.
I found a query for getting a tweets from a specifies user. Can we add fromDate and toDate parameter in this query?
This is about a different API, not Premium: /1.1/statuses/user_timeline endpoint does not have a from date or to date. Instead, it has a since_id and max_id which are tweet IDs (any tweet ids, it just has to be a valid format, doesnât have to be a valid tweet). See here: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/guides/working-with-timelines (the images seem to be broken here at the moment too)
Hope that helps!
Thankyou @IgorBrigadir for your responses. I still have some queries which I would like to confirm.
-
POST "https://api.twitter.com/1.1/tweets/search/:product/:label.json" -d '{"query":âfrom:User1 OR from:User2 OR from:User3"search api"","maxResults":"500","fromDate":"<yyyymmddhhmm>","toDate":"<yyyymmddhhmm>"}' -H "Authorization: Bearer TOKEN"
Will the above query provide only provide the tweets in which the users are mentioned? OR
It also provide tweets written by those users or not (this results are from user network search)?
-
GET https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2
As per our previous discussion,there are no date parameters but is there a way to write above query for multiple users
3. POST "https://api.twitter.com/1.1/tweets/search/:product/:label.json" -d '{"query":"TwitterDev "search api"","maxResults":"500","fromDate":"<yyyymmddhhmm>","toDate":"<yyyymmddhhmm>", "value":"from:twitterdev OR from:nadeem" }' -H "Authorization: Bearer TOKENâ
In above query can we add the value field for specifying the users as given in the query. Is this query correct?.
If not please provide a way to specify the user names in Search query.
Thankyou for your responses. I still have some queries which I would like to confirm.
-
POST "https://api.twitter.com/1.1/tweets/search/:product/:label.json" -d '{"query":âfrom:User1 OR from:User2 OR from:User3"search api"","maxResults":"500","fromDate":"<yyyymmddhhmm>","toDate":"<yyyymmddhhmm>"}' -H "Authorization: Bearer TOKEN"
Will the above query provide only the tweets in which the users are mentioned? OR
Will it also provide tweets written by those user?
-
GET https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2
As per the discussion,there are no date parameters but is there a way to write above query for multiple users
-
POST "https://api.twitter.com/1.1/tweets/search/:product/:label.json" -d '{"query":"TwitterDev "search api"","maxResults":"500","fromDate":"<yyyymmddhhmm>","toDate":"<yyyymmddhhmm>", "value":"from:twitterdev OR from:nadeem" }' -H "Authorization: Bearer TOKENâ
Can we add the value field for specifying the users as given in the query. Is this query correct?.
If not please provide a way to specify the user names in Search query.
-
from: will only match tweets authored by the user specified. It will not match mentions or replies to them.
-
No, you have to issue a separate call for each user for this endpoint.
-
See https://developer.twitter.com/en/docs/twitter-api/premium/rules-and-filtering/using-premium-operators on how to build queries properly. Spaces are implicit logical AND, so if you want tweets from @TwitterDev that mention search API your query would be:
"query":"from:TwitterDev \"search api\""
or if itâs any mention, not just from @TwitterDev itâs:
"query":"TwitterDev \"search api\""
As presented your queries are not correct, because they have mismatched and unescaped quotes and placeholders. Instead of writing your queries manually i recommend using a command line tool like Twarc https://scholarslab.github.io/learn-twarc/ to get the tweets to start out with.
system
closed
#10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.