Retrieve search results by keyword
Returns array of tweets provided by Twitter search page. Typically Twitter returns ~20 results per page. You can request additional search results by sending another request to the same endpoint using cursor parameter.
Endpoint
Endpoint parameters
Name | Description | Example |
---|---|---|
query (Required) | A UTF-8, URL-encoded search query , including any operators supported by Twitter website search. | from:elonmusk doge |
cursor (Optional) | Cursor value obtained from next_cursor response property | DAACCgACGC12FhmAJxAKAAMYLXYWGX_Y8AgABAAAAAILAAUAAADoRW1QQzZ3QUFBZlEvZ0d... |
type (Optional) | Search type (Latest for recent tweets or Top for popular tweets) Default: Latest | Top |
For additional details on Twitter search operators refer to the following overview: https://github.com/igorbrigadir/twitter-advanced-search.
Using search to obtain tweets and replies
The search endpoint can be used to obtain tweets and replies made by a specific user,
There is no dedicated endpoint to extract tweets from a user timeline, but the same can be achieved using GET /twitter/search
endpoint and Twitter search operators:
from:[USERNAME]
will return all tweets and replies made by userfrom:[USERNAME] filter:replies
will return only replies, but not tweetsfrom:[USERNAME] -filter:replies
will return only tweets, but not replies
Append max_id:[TWEET_ID]
with the lowest tweet ID from the previous response to retrieve more tweets.
Retrieving large datasets
While Twitter returns a limited number of results when using "Latest" search filter, it is possible to cycle through a larger dataset using max_id:
and since_id:
search operators.
When retrieving Latest search results, Twitter provides the response with tweets sorted by ID in descending order. If you need to retrieve more posts - simply make another request with the same query adding max_id:[lowest ID from current dataset].
Using this approach it is possible to extract the entire timeline from the moment an account was registered.
Response codes
HTTP 200 OK - succeeded
HTTP 402 Payment Required - not enough credits to perform this request
HTTP 404 Not Found - requested tweet does not exist
HTTP 422 Unprocessable Content - validation failed (e.g. one of the required parameters was not provided)
HTTP 500 Internal Server Error - other error, typically means that SocialData API failed to obtain the requested information and you should try again later
Rate limits
By default this endpoint will process up to 120 requests per minute. Please reach out to support@socialdata.tools if you need to raise your rate limit.
Example request
Example response
Last updated