API Docs - v1.0.3¶
Source¶
twitter (Source)¶
The twitter source receives the events from a twitter App.
Syntax
@source(type="twitter", consumer.key="<STRING>", consumer.secret="<STRING>", access.token="<STRING>", access.token.secret="<STRING>", mode="<STRING>", filter.level="<STRING>", track="<STRING>", follow="<LONG>", location="<DOUBLE>", language="<STRING>", query="<STRING>", count="<STRING>", geocode="<STRING>", result.type="<STRING>", max.id="<LONG>", since.id="<LONG>", until="<STRING>", polling.interval="<LONG>", @map(...)))
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
consumer.key | Consumer key is the API key to access created twitter app | STRING | No | No | |
consumer.secret | Consumer secret is the API secret to access created twitter app | STRING | No | No | |
access.token | Access token is used to make API requests on behalf of your account. | STRING | No | No | |
access.token.secret | Access token secret is used to make API requests on behalf of your account. | STRING | No | No | |
mode | There are two possible values for mode. 1. Streaming - Retrieves real time tweets, 2. TwitterPoller - Retrieves historical tweets within one week. |
STRING | No | No | |
filter.level | Filters tweets by the level of engagement based on the filter.level. The highest level(medium) corresponds loosely to the ?top tweets? filter the service already offers in its on-site search function. Values will be one of either none, low, or medium. | none | STRING | Yes | No |
track | Filters the tweets that include the given keywords. | null | STRING | Yes | No |
follow | Filters the tweets that is tweeted by the given user ids | null | LONG | Yes | No |
location | Filters tweets based on the locations. Here, We have to specify latitude and the longitude of the location. For Example : 51.683979:0.278970 | null | DOUBLE | Yes | No |
language | Filters tweets in the given language, given by an ISO 639-1 code. | null | STRING | Yes | No |
query | Filters tweets that matches the given Query, UTF-8, URL-encoded search query of 500 characters maximum, including operators. For example : '@NASA' - mentioning Twitter account 'NASA'. |
null | STRING | Yes | No |
count | Returns specified number of tweets per page, up to a maximum of 100. | null | STRING | Yes | No |
geocode | Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by latitude,longitude,radius, where radius units must be specified as either ? mi ? (miles) or ? km ? (kilometers). | null | STRING | Yes | No |
result.type | Returns tweets based on what type of results you would prefer to receive. The current default is 'mixed'. Valid values include: mixed : Include both popular and recent results in the response. recent : return only the most recent results in the response * popular : return only the most popular results in the response.) |
mixed | STRING | Yes | No |
max.id | Returns tweets with an tweet ID less than (that is, older than) or equal to the specified ID | -1 | LONG | Yes | No |
since.id | Returns tweets with an tweet ID greater than (that is, more recent than) the specified ID. | -1 | LONG | Yes | No |
until | Returns tweets created before the given date. Date should be formatted as YYYY-MM-DD. Search index has a 7-day limit. So no tweets will be found for a date older than one week. | null | STRING | Yes | No |
polling.interval | Specifies the period of time (in seconds) to poll tweets periodically | 3600 | LONG | Yes | No |
Examples EXAMPLE 1
@source(type='twitter', consumer.key='consumer.key',consumer.secret='consumerSecret', access.token='accessToken',access.token.secret='accessTokenSecret', mode= 'streaming', @map(type='json', fail.on.missing.attribute='false', attributes(created_at = 'created_at', id = 'id' ,id_str = 'id_str', text = 'text'))) define stream rcvEvents(created_at String, id long, id_str String, text String);
Under this configuration, it starts listening on random sample of public statuses and they are passed to the rcvEvents stream.
EXAMPLE 2
@source(type='twitter', consumer.key='consumer.key',consumer.secret='consumerSecret', access.token='accessToken',access.token.secret='accessTokenSecret', mode= 'streaming', track = 'Amazon,Google,Apple', language = 'en', @map(type='json', fail.on.missing.attribute='false' , attributes(created_at = 'created_at', id = 'id' ,id_str = 'id_str', text = 'text'))) define stream rcvEvents(created_at String, id long, id_str String, text String);
Under this configuration, it starts listening tweets in English that containing the keywords Amazon,google or apple and they are passed to the rcvEvents stream.
EXAMPLE 3
@source(type='twitter', consumer.key='consumer.key',consumer.secret='consumerSecret', access.token='accessToken',access.token.secret='accessTokenSecret', mode= 'streaming', track = 'Amazon,Google,Apple', language = 'en', follow = '11348282,20536157,15670515,17193794,58561993,18139619',filter.level = 'low', location = '51.280430:-0.563160,51.683979:0.278970', @map(type='json', fail.on.missing.attribute='false' , attributes(created_at = 'created_at', id = 'id' ,id_str = 'id_str', text = 'text'))) define stream rcvEvents(created_at String, id long, id_str String, text String);
Under this configuration, it starts listening tweets in English that containing the keywords Amazon,google,apple or tweeted by the given followers or tweeted from the given location based on the filter.level. and they are passed to the rcvEvents stream.
EXAMPLE 4
@source(type='twitter', consumer.key='consumer.key',consumer.secret='consumerSecret', access.token='accessToken',access.token.secret='accessTokenSecret', mode= 'polling', query = 'happy hour', @map(type='json', fail.on.missing.attribute='false' , attributes(created_at = 'created_at', id = 'id' ,id_str = 'id_str', text = 'text'))) define stream rcvEvents(created_at String, id long, id_str String, text String);
Under this configuration, it starts polling tweets containing the exact phrase 'happy hour' and they are passed to the rcvEvents stream.
EXAMPLE 5
@source(type='twitter', consumer.key='consumer.key',consumer.secret='consumerSecret', access.token='accessToken',access.token.secret='accessTokenSecret', mode= 'polling', query = '#Amazon', since.id = '973439483906420736', @map(type='json', fail.on.missing.attribute='false' , attributes(created_at = 'created_at', id = 'id' ,id_str = 'id_str', text = 'text'))) define stream rcvEvents(created_at String, id long, id_str String, text String);
Under this configuration, it starts polling tweets, containing the hashtag '#Amazon' and tweet Id is greater than since.id and they are passed to the rcvEvents stream.
EXAMPLE 6
@source(type='twitter', consumer.key='consumer.key',consumer.secret='consumerSecret', access.token='accessToken',access.token.secret='accessTokenSecret', mode= 'polling', query = '@NASA', language = 'en', result.type = 'recent', geocode = '43.913723261972855,-72.54272478125,150km', since.id = 24012619984051000, max.id = 250126199840518145, until = 2018-03-10, @map(type='json', fail.on.missing.attribute='false' , attributes(created_at = 'created_at', id = 'id' ,id_str = 'id_str', text = 'text'))) define stream rcvEvents(created_at String, id long, id_str String, text String);
Under this configuration, it starts polling recent tweets in english that is having tweet id greater than since.id and less than max.id, mentioning NASA and they are passed to the rcvEvents stream.