The streaming API tracks strings, and URLs are just a kind of string. The statuses/filter.json method of the streaming API lets you supply a “track” parameter with comma-separated strings that you’re matching for on the streaming API. If you URL-encode a URL as one of those strings and start listening to the stream, you’ll be streamed a tweet every time that URL is tweeted or retweeted (provided that tweets containing that URL make up no more than 1% of all tweets happening at that moment – in all likelihood not an issue for a single URL). As each tweet comes in, you count them. You won’t be streamed deletes or unretweets this way, but it’s enough to get started with.
A single-URL example:
curl -u user:password “https://stream.twitter.com/1/statuses/filter.json” -d “track=https%3A%2F%2Fdev.twitter.com%2Fdiscussions%2F5653”
{
"favorited":false,
"text":"Testing link https:\/\/t.co\/jvivDycK",
"possibly_sensitive_editable":true,
"truncated":false,
"created_at":"Fri Feb 10 15:51:21 +0000 2012",
"retweeted":false,
"retweet_count":0,
"coordinates":null,
"source":"\u003Ca href=\"http:\/\/realitytechnicians.com\" rel=\"nofollow\"\u003EOAuth Dancer Reborn\u003C\/a\u003E",
"in_reply_to_status_id_str":null,
"possibly_sensitive":false,
"entities":
{
"user_mentions":
[
],
"urls":
[
{
"indices":
[
13,
34
],
"url":"https:\/\/t.co\/jvivDycK",
"display_url":"dev.twitter.com\/discussions\/56\u2026",
"expanded_url":"https:\/\/dev.twitter.com\/discussions\/5653"
}
],
"hashtags":
[
]
},
"geo":null,
"in_reply_to_user_id_str":null,
"place":null,
"in_reply_to_user_id":null,
"in_reply_to_screen_name":null,
"id_str":"167999101609320448",
"user":
{
"default_profile":false,
"notifications":null,
"profile_use_background_image":true,
"time_zone":null,
"created_at":"Wed Mar 03 19:37:35 +0000 2010",
"verified":false,
"geo_enabled":true,
"profile_text_color":"333333",
"profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/80151733\/oauth-dance.png",
"description":"",
"default_profile_image":false,
"profile_link_color":"0084B4",
"url":"http:\/\/bit.ly\/oauth-dancer",
"follow_request_sent":null,
"favourites_count":6,
"lang":"en",
"profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/80151733\/oauth-dance.png",
"profile_background_color":"C0DEED",
"followers_count":23,
"profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/730275945\/oauth-dancer_normal.jpg",
"contributors_enabled":false,
"profile_background_tile":true,
"protected":false,
"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/730275945\/oauth-dancer_normal.jpg",
"location":"San Francisco,
CA",
"profile_sidebar_fill_color":"DDEEF6",
"name":"OAuth Dancer",
"id_str":"119476949",
"listed_count":0,
"following":null,
"screen_name":"oauth_dancer",
"id":119476949,
"is_translator":false,
"show_all_inline_media":false,
"statuses_count":153,
"utc_offset":null,
"friends_count":14,
"profile_sidebar_border_color":"C0DEED"
},
"id":167999101609320448,
"contributors":null,
"in_reply_to_status_id":null
}