A jQuery plugin for working with the Twitter Search API and putting twitter searches on websites with a simple syntax that follows the Twitter Search API URL parameters. The jQuery fn twitter plugin fills each element in the collection it operates on with an unordered list of twitter statuses based on the options passed in.
$('#demoList').twitter({from: 'mediatemple', replies: false}) ← Click to run this codeThe jQuery Twitter Plugin provides two methods and a public default options object:
options: the string or object used to configure the search
callback: the function to run when the results come back from twitter. Three arguments are passed to this callback(tweets, query, exclusionsExp)
This method allows you to get twitter results and work with the JSON response. Fore example:
options: the string or object used to configure the search
This method uses $.twitter() internally to go and get the tweets you ask for, and render them in a <ul> within each element in the jQuery collection you call it on. For example:
This is the publicly available object that $.twitter() and $.fn.twitter() use to configure twitter searches. You can override it at the beginning of your code to prevent yourself from repeating configurations unnecessarily. For example:
You can pass the default Twitter Search API Parameters to $.fn.twitter() as properties of the options object:
Default query
All of these words
This exact phrase
Any of these words
None of these word
This hashtag
Written in language
From this person
To this person
Referencing this person
Near this place
Within this distance
Distance unit (miles or kilometers)
Since this date
Until this date
Attitude: '?' or ':)' or ':)'
Containing: 'links'
Include retweet?: 'retweets'
Results per page
In addition to supporting the default Twitter Search API URL parameters, $.fn.twitter() also supports five options for filtering out mentions and retweets and for handling no results cases client side.
Number of tweets to get. Maps to and supersedes rpp (results per page).
Space delimited list of strings (eg: '_ s gr @b'). Use this to exclude tweets containing strings that are part of a word
Include user avatars? true by default. (Boolean)
Text to display if no results are found
Include replies? (Boolean)
Include retweets (Boolean)