Fetching tweets with jQuery and the Twitter JSON API

Just thought it’d be nice to share this little script that fetches tweets using a jQuery AJAX request and the Twitter API. The script is based on a snippet I picked up from my good friend Sven Lito.

I’ve added verbose comments in the code itself, so let’s keep this post short 😉

This post is pretty old… I posted a newer version of something like this here.

The javascript

The markup

Categories: Uncategorized
  • Wangnana_bg

    can you ask you a question? How can I use ‘http://search.twitter.com/search.json?q=’ to grab all the messages.after trying,I find the date and sum of messages is limited,how can I get the old messages? I ‘m hurrying to look for the answer.

  • chrisiufer

    thanks. I landed here because I needed a way to parse the created_at date. Lo and behold the Date() object can do it natively. I dont know how I completely looked over that.

  • Israel Morales

    This is awesome! thannks

  • http://twitter.com/robguerra6 Roberto Guerra Soto

    Hi, great post but  in some cases tweet.id can lose accuracy to solve this can use tweet.id_str

  • Virginie

    Hello, I’ve used your code, and it seems to be working fine, but when I click on the tweet, it doesn’t fetch the right ID, and leads to an error page. Would you know why? http://www.fluonoir.com
    Thank you.

    • lupomontero

      Hi Virginie, the code in this article is pretty old and might be a bit buggy. I posted a newer version (as a jQuery plugin) here http://lupomontero.e-noise.com/blog/jquery-plugin-to-fetch-tweets-using-the-twitter-json-api

  • http://vinodkumartiwari.wordpress.com/ Vinod

    This was really helpful.

  • Matthew

    Is there a way to limit the amount of tweets that are fetched for the feed? i.e. limit the feed to only fetch the latest two tweets.

    • lupomontero

      Try the “rpp” parameter in the query string used to load the tweets. In the example this has a value of 5… something like: