The Twitter’s Standard search API (search/tweets) allows simple queries against the indices of recent or popular Tweets. This Source
provides continuous searches against a sampling of recent Tweets published in the past 7 days. Part of the 'public' set of APIs.
Returns a collection of relevant Tweets matching a specified query.
Use the spring.cloud.stream.poller
properties to control the interval between consecutive search requests. Rate Limit - 180 requests per 30 min. window (e.g. ~6 r/m, ~ 1 req / 10 sec.)
The twitter.search
query properties allows querying by keywords and filter the result by time and geolocation.
The twitter.search.count
and twitter.search.page
control the result pagination in accordance with to the Search API.
Note: Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
Properties grouped by prefix:
- cron
-
Cron expression for polling. Mutually exclusive with 'fixedDelay' and 'fixedRate'. (String, default:
<none>
) - fixed-delay
-
Polling delay period. Mutually exclusive with 'cron' and 'fixedRate'. (Duration, default:
<none>
) - fixed-rate
-
Polling rate period. Mutually exclusive with 'fixedDelay' and 'cron'. (Duration, default:
<none>
) - initial-delay
-
Polling initial delay. Applied for 'fixedDelay' and 'fixedRate'; ignored for 'cron'. (Duration, default:
<none>
) - max-messages-per-poll
-
Maximum number of messages to poll per polling cycle. (Integer, default:
<none>
) - receive-timeout
-
How long to wait for messages on poll. (Duration, default:
1s
)
- access-token
-
Your Twitter token. (String, default:
<none>
) - access-token-secret
-
Your Twitter token secret. (String, default:
<none>
) - consumer-key
-
Your Twitter key. (String, default:
<none>
) - consumer-secret
-
Your Twitter secret. (String, default:
<none>
) - debug-enabled
-
Enables Twitter4J debug mode. (Boolean, default:
false
) - raw-json
-
Enable caching the original (raw) JSON objects as returned by the Twitter APIs. When set to False the result will use the Twitter4J's json representations. When set to True the result will use the original Twitter APISs json representations. (Boolean, default:
true
)
- count
-
Number of tweets to return per page (e.g. per single request), up to a max of 100. (Integer, default:
100
) - lang
-
Restricts searched tweets to the given language, given by an http://en.wikipedia.org/wiki/ISO_639-1 . (String, default:
<none>
) - page
-
Number of pages (e.g. requests) to search backwards (from most recent to the oldest tweets) before start the search from the most recent tweets again. The total amount of tweets searched backwards is (page * count) (Integer, default:
3
) - query
-
Search tweets by search query string. (String, default:
<none>
) - restart-from-most-recent-on-empty-response
-
Restart search from the most recent tweets on empty response. Applied only after the first restart (e.g. when since_id != UNBOUNDED) (Boolean, default:
false
) - result-type
-
Specifies what type of search results you would prefer to receive. The current default is "mixed." Valid values include: mixed : Include both popular and real time results in the response. recent : return only the most recent results in the response popular : return only the most popular results in the response (ResultType, default:
<none>
, possible values:popular
,mixed
,recent
) - since
-
If specified, returns tweets with since the given date. Date should be formatted as YYYY-MM-DD. (String, default:
<none>
)
java -jar twitter-search-source.jar
--twitter.connection.consumerKey= ...
--twitter.connection.consumerSecret= ...
--twitter.connection.accessToken= ...
--twitter.connection.accessTokenSecret= ...
--twitter.search.query=Amsterdam
--twitter.search.count=30
--twitter.search.page=3
And here is an example pipeline that uses twitter-search:
twitter-search-stream= twitter-search --twitter.connection.consumerKey= ... --twitter.connection.consumerSecret= ... --twitter.connection.accessToken= ... --twitter.connection.accessTokenSecret= ... --twitter.search.query=Amsterdam --twitter.search.count=30 --twitter.search.page=3