TwitterUserTimeline

TwitterUserTimeline datasource the tweets from a specific user timeline. With Hooks Query Language you can customize what data you want to receive:

Input Output Credits Freshness
TwitterScreenName (String) Tweet Twitter 5 minute

What you can get from this API

  • Get all tweets from un user timeline
  • Get all tweets from a user that match a certain condition, like they are retweets, who created them, if they have images …

How to Use

As every datasource at Hooks, you can choose to pull the data in your preferred format or to set up a webhook to receive the data when something happens.  

As we offer many datasources, we have developed a custom SQL-Like language (Hooks Query Language) to be able to query each datasource in the same format. To create a subscription the first thing you need to do is to define an HQL query and then send this query to create subscription endpoint.

RSS datasource has a mandatory parameter twitter_query and you can use an optional WHERE clause to filter the output data (Tweet) in order to receive just what you need. Hooks will then call your webhook once new data is available for your query. 

Step 1: Customize subscription

Hooks provide an elegant mechanism for creating subscriptions using Hooks Query Language. It has a similar notation to SQL and lets you define each subscription with a simple HQL query.

The following query will create a subscription to “Send me all the tweets for the query Techstars”:

SELECT * FROM TwitterUserTimeline('Techstars')

Once this HQL query has new results -New tweets for the account ‘Techstars’- Hooks will send a Tweet object to your webhook:


 {
"_entity_type": "tweet",
"_id": "tweet_976733289221210112",
"contributors": null,
"coordinates": null,
"created_at": "Thu Mar 22 08:12:17 +0000 2018",
"entities": {
"hashtags": [
{
"indices": [
121,
132
],
"text": "3Dprinting"
}
],
"symbols": [],
"urls": [],
"user_mentions": [
{
"id": 117789943,
"id_str": "117789943",
"indices": [
3,
19
],
"name": "StanleyBlack&Decker",
"screen_name": "StanleyBlkDeckr"
},
{
"id": 14277276,
"id_str": "14277276",
"indices": [
61,
71
],
"name": "techstars",
"screen_name": "techstars"
}
]
},
"favorite_count": 0,
"favorited": false,
"geo": null,
"id": 976733289221210112,
"id_str": "976733289221210112",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"place": null,
"retweet_count": 7,
"retweeted": false,
"retweeted_status": {
"contributors": null,
"coordinates": null,
"created_at": "Wed Mar 21 20:37:05 +0000 2018",
"entities": {
"hashtags": [
{
"indices": [
100,
111
],
"text": "3Dprinting"
}
],
"symbols": [],
"urls": [
{
"display_url": "twitter.com\/i\/web\/status\/9\u2026",
"expanded_url": "https:\/\/twitter.com\/i\/web\/status\/976558334030442498",
"indices": [
117,
140
],
"url": "https:\/\/t.co\/6GWviWvVd1"
}
],
"user_mentions": [
{
"id": 14277276,
"id_str": "14277276",
"indices": [
40,
50
],
"name": "techstars",
"screen_name": "techstars"
}
]
},
"favorite_count": 11,
"favorited": false,
"geo": null,
"id": 976558334030442498,
"id_str": "976558334030442498",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"place": null,
"possibly_sensitive": false,
"retweet_count": 7,
"retweeted": false,
"source": "<a href=\"http:\/\/percolate.com\" rel=\"nofollow\">Percolate<\/a>",
"text": "Ahead of the Stanley+Techstars program, @Techstars leaders visited us to see how we've incorporated #3Dprinting and\u2026 https:\/\/t.co\/6GWviWvVd1",
"truncated": true,
"user": {
"contributors_enabled": false,
"created_at": "Fri Feb 26 16:34:00 +0000 2010",
"default_profile": false,
"default_profile_image": false,
"description": "Official Twitter account for Stanley Black and Decker",
"entities": {
"description": {
"urls": []
},
"url": {
"urls": [
{
"display_url": "stanleyblackanddecker.com",
"expanded_url": "http:\/\/stanleyblackanddecker.com",
"indices": [
0,
22
],
"url": "http:\/\/t.co\/OwfwWAucUP"
}
]
}
},
"favourites_count": 474,
"follow_request_sent": false,
"followers_count": 5293,
"following": false,
"friends_count": 170,
"geo_enabled": false,
"has_extended_profile": false,
"id": 117789943,
"id_str": "117789943",
"is_translation_enabled": false,
"is_translator": false,
"lang": "en",
"listed_count": 136,
"location": "New Britain",
"name": "StanleyBlack&Decker",
"notifications": false,
"profile_background_color": "C0DEED",
"profile_background_image_url": "http:\/\/pbs.twimg.com\/profile_background_images\/84200087\/stanley_twitter_nologos.jpg",
"profile_background_image_url_https": "https:\/\/pbs.twimg.com\/profile_background_images\/84200087\/stanley_twitter_nologos.jpg",
"profile_background_tile": false,
"profile_banner_url": "https:\/\/pbs.twimg.com\/profile_banners\/117789943\/1501159100",
"profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/534427580120571905\/qEDM5_-D_normal.jpeg",
"profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/534427580120571905\/qEDM5_-D_normal.jpeg",
"profile_link_color": "0084B4",
"profile_sidebar_border_color": "C0DEED",
"profile_sidebar_fill_color": "FFD30D",
"profile_text_color": "333333",
"profile_use_background_image": true,
"protected": false,
"screen_name": "StanleyBlkDeckr",
"statuses_count": 1239,
"time_zone": null,
"translator_type": "none",
"url": "http:\/\/t.co\/OwfwWAucUP",
"utc_offset": null,
"verified": false
}
},
"source": "<a href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\">Twitter for iPhone<\/a>",
"text": "RT @StanleyBlkDeckr: Ahead of the Stanley+Techstars program, @Techstars leaders visited us to see how we've incorporated #3Dprinting and ad\u2026",
"truncated": false,
"user": {
"contributors_enabled": false,
"created_at": "Mon Jul 27 04:06:55 +0000 2015",
"default_profile": true,
"default_profile_image": false,
"description": "Humble Star",
"entities": {
"description": {
"urls": []
}
},
"favourites_count": 51,
"follow_request_sent": false,
"followers_count": 26,
"following": false,
"friends_count": 74,
"geo_enabled": false,
"has_extended_profile": false,
"id": 3296795162,
"id_str": "3296795162",
"is_translation_enabled": false,
"is_translator": false,
"lang": "en",
"listed_count": 0,
"location": "",
"name": "Munkhi Tse",
"notifications": false,
"profile_background_color": "C0DEED",
"profile_background_image_url": "http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png",
"profile_background_image_url_https": "https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png",
"profile_background_tile": false,
"profile_banner_url": "https:\/\/pbs.twimg.com\/profile_banners\/3296795162\/1520835673",
"profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/973081082500235264\/46urpcv1_normal.jpg",
"profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/973081082500235264\/46urpcv1_normal.jpg",
"profile_link_color": "1DA1F2",
"profile_sidebar_border_color": "C0DEED",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": true,
"protected": false,
"screen_name": "Munkhitse",
"statuses_count": 53,
"time_zone": "Pacific Time (US & Canada)",
"translator_type": "none",
"url": null,
"utc_offset": -25200,
"verified": false
}
}

Please take a look at the above object. You can use WHERE clause to filter all the properties of the Tweet object and only get updates on what you need:

The following HQL query will send you updates only for tweets with more than 20 favs:

SELECT * FROM
RSS('Techstars')
WHERE favorite_count > 20

This returns:

{
"_entity_type": "tweet",
"_id": "tweet_976728097008562176",
"contributors": null,
"coordinates": null,
"created_at": "Thu Mar 22 07:51:39 +0000 2018",
"entities": {
"hashtags": [],
"symbols": [],
"urls": [],
"user_mentions": [
{
"id": 92547778,
"id_str": "92547778",
"indices": [
3,
19
],
"name": "Clarence Bethea",
"screen_name": "Clarence_Bethea"
},
{
"id": 14277276,
"id_str": "14277276",
"indices": [
74,
84
],
"name": "techstars",
"screen_name": "techstars"
}
]
},
"favorite_count": 55,
"favorited": false,
"geo": null,
"id": 976728097008562176,
"id_str": "976728097008562176",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"place": null,
"retweet_count": 26,
"retweeted": false,
"retweeted_status": {
"contributors": null,
"coordinates": null,
"created_at": "Wed Mar 21 16:26:15 +0000 2018",
"entities": {
"hashtags": [],
"symbols": [],
"urls": [
{
"display_url": "twitter.com/i/web/status/9…",
"expanded_url": "https://twitter.com/i/web/status/976495209709297667",
"indices": [
116,
139
],
"url": "https://t.co/S1R7xAkb1z"
}
],
"user_mentions": [
{
"id": 14277276,
"id_str": "14277276",
"indices": [
53,
63
],
"name": "techstars",
"screen_name": "techstars"
}
]
},
"favorite_count": 83,
"favorited": false,
"geo": null,
"id": 976495209709297667,
"id_str": "976495209709297667",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "en",
"metadata": {
"iso_language_code": "en",
"result_type": "recent"
},
"place": null,
"retweet_count": 26,
"retweeted": false,
"source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
"text": "I keep hearing founders are stuck on giving up 6% to @techstars to do the program. We just completed the program 6… https://t.co/S1R7xAkb1z",
"truncated": true,
"user": {
"contributors_enabled": false,
"created_at": "Wed Nov 25 15:40:58 +0000 2009",
"default_profile": false,
"default_profile_image": false,
"description": "Husband, Father & Friend - Founder & CEO @UpsieHQ l @villagecapital 16' @Techstars 17'",
"entities": {
"description": {
"urls": []
},
"url": {
"urls": [
{
"display_url": "upsie.com",
"expanded_url": "https://upsie.com/",
"indices": [
0,
23
],
"url": "https://t.co/wMMz2E8Zmp"
}
]
}
},
"favourites_count": 15738,
"follow_request_sent": false,
"followers_count": 1779,
"following": false,
"friends_count": 1770,
"geo_enabled": true,
"has_extended_profile": false,
"id": 92547778,
"id_str": "92547778",
"is_translation_enabled": false,
"is_translator": false,
"lang": "en",
"listed_count": 133,
"location": "Minneapolis, MN",
"name": "Clarence Bethea",
"notifications": false,
"profile_background_color": "31312D",
"profile_background_image_url": "http://pbs.twimg.com/profile_background_images/378800000032083215/a0e9d0e5a86521774cbac1156b1b8287.jpeg",
"profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/378800000032083215/a0e9d0e5a86521774cbac1156b1b8287.jpeg",
"profile_background_tile": true,
"profile_banner_url": "https://pbs.twimg.com/profile_banners/92547778/1508180200",
"profile_image_url": "http://pbs.twimg.com/profile_images/778726447389159424/0EmcquR8_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/778726447389159424/0EmcquR8_normal.jpg",
"profile_link_color": "54544F",
"profile_sidebar_border_color": "FFFFFF",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": false,
"protected": false,
"screen_name": "Clarence_Bethea",
"statuses_count": 9098,
"time_zone": "Central Time (US & Canada)",
"translator_type": "none",
"url": "https://t.co/wMMz2E8Zmp",
"utc_offset": -18000,
"verified": false
}
},
"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
"text": "RT @Clarence_Bethea: I keep hearing founders are stuck on giving up 6% to @techstars to do the program. We just completed the program 6 mon…",
"truncated": false,
"user": {
"contributors_enabled": false,
"created_at": "Sat Jul 26 00:45:40 +0000 2014",
"default_profile": false,
"default_profile_image": false,
"description": "JGM input output. Enjoying life through my partner, colleagues, learning, and working. #GiveFirst, #CTO, #productowner, #finance, #gamedesign #Techstars",
"entities": {
"description": {
"urls": []
},
"url": {
"urls": [
{
"display_url": "linkedin.com/in/jgmio",
"expanded_url": "https://www.linkedin.com/in/jgmio",
"indices": [
0,
23
],
"url": "https://t.co/qNNFecz3b2"
}
]
}
},
"favourites_count": 1575,
"follow_request_sent": false,
"followers_count": 819,
"following": false,
"friends_count": 2555,
"geo_enabled": true,
"has_extended_profile": false,
"id": 2724690335,
"id_str": "2724690335",
"is_translation_enabled": false,
"is_translator": false,
"lang": "en",
"listed_count": 162,
"location": "Antwerp",
"name": "JGM.io",
"notifications": false,
"profile_background_color": "131516",
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme14/bg.gif",
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme14/bg.gif",
"profile_background_tile": true,
"profile_banner_url": "https://pbs.twimg.com/profile_banners/2724690335/1457974637",
"profile_image_url": "http://pbs.twimg.com/profile_images/768056434466627584/8pKq69VX_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/768056434466627584/8pKq69VX_normal.jpg",
"profile_link_color": "009999",
"profile_sidebar_border_color": "EEEEEE",
"profile_sidebar_fill_color": "EFEFEF",
"profile_text_color": "333333",
"profile_use_background_image": true,
"protected": false,
"screen_name": "JGM_io",
"statuses_count": 2875,
"time_zone": "London",
"translator_type": "none",
"url": "https://t.co/qNNFecz3b2",
"utc_offset": 0,
"verified": false
}
}

Optional: Pull the data

You can use fetch endpoint to request the data currently available for your HQL query. Hooks will return the latest data available for HQL query. The result may be empty if we currently don’t have any data available for your query.

To pull the data for “All new feed items of The Next Web RSS feed with a title contains ‘programmers'” you can use:

SELECT * FROM
TwitterUserTimeline('YCombinator')
WHERE text like '%programmers%'

This query will return all recent Tweets for the user ‘YCombinator’ where the name containes the string “programmers”.

Step 2: Create subscription

To create a subscription you just need to send an HQL query and a title of your choice to subscriptions endpoint:

curl -H "Content-type: application/json" -d '{
	"query": "SELECT * FROM TwitterUserTimeline(\'hooks\') WHERE text like \'%rocks%\'"
}' 'http://api.hooksdata.io/v1/subscriptions'

Hooks will then create a subscription on our servers and call your webhook once new data is available for your query.

Examples

Using HQL you can customize what data you want to select from a datasource and also filter the output using a WHERE clause. The following examples show how you can use HQL to choose just the data you need:

Tweets from the account ‘hooksapp’ with a text containing ‘programmers’.

SELECT * FROM
TwitterUserTimeline('hooksapp')
WHERE text like '%programmers%'

Tweets from the account ‘ladygaga’ that are retweets.

SELECT * FROM
TwitterUserTimeline('ladygaga')
WHERE text like 'RT %'

Tweets from the account ‘ycombinator’ with more than 5 retweets

SELECT * FROM
TwitterUserTimeline('ycombinator')
WHERE retweet_count > 5