Get a tweet stream JSON object client-side without exposing a private auth token, and without any server-side code or oauth. Compatible with Twitter API version 1.1 and above.
1 person uses it

Angular Tweets

Get a tweet stream client-side without exposing a private auth token, and without any server-side code.

The stream will be provided to you via an ordinary $http promise object.

How does it work?

Twitter has a tight lock on its API. You can't access any API data without a token. However there is a back door, the official Twitter widget which returns HTML.

This module works by scraping the official twitter widget and parsing the result into JSON.

The official twitter widget makes a JSONP call to an API. It does this using a public widget id which allows access to the tweet stream from a single pre-chosen user.

This API call returns a JSON object full of HTML which the widget normally displays in an iframe.

This service pulls that stream, extracts the HTML and reverse engineers it back into a JSON object which can be saved in scope.

Once the tweet stream is in scope you can do what you like with it.

Can I get a demo?

You can find a working plunkr here.


Kudos to Jason Mayes for the idea


Acquiring a widget ID

First go here and create a new widget. Configure the widget to your liking. The data from the widget will be used to compose the response. Inspect the generated widget code and grab the public widget ID. You will need this to configure the service.

You will not need an API key, secret, etc, etc.

Using the service

Inject "ngTweets" into your app. The module provides a service called tweets. Call tweets.get and pass it your widget ID. You will get back an $http promise object which you can interact with in the usual way.

The controller:

The view:

Sample response

You will receive an object containing a header, and an array with a maximum of 20 tweets.

Error handling

The header object contains information about any errors that occurred upstream. The header status would normally be 200. Anything else is an error.

Downstream errors are currently not handled. Please feel free to submit a patch for this.


Please feel free to contribute by forking this repository and submitting a pull request. Contributors will be credited in this Readme.

About me

I'm an Angular developer and trainer working out of Brighton, England. You can find Angular lessons on my website here

Browser compatibility

IE9+ only please. It should work everywhere Angular 1.3.1 works.

Likelihood of failure

Because this service works by scraping HTML, it will fail if the HTML changes. This could happen at any time without warning. Caution is advised.


This plugin is a dirty low down (albeit functional) hack. My assumption is that this hack is likely to remain available as long as older browsers require JSONP to access the API. However I can make no guarantees on this. This is not an official twitter API, there is no uptime guarantee, Twitter can turn it off at any time.

Caution is advised. Use at your discretion. I take no responsibility for any problems of any kind you may encounter, technical, legal, spiritual, military, etc.


MIT license, use it as you see fit. I'm not going to sue you.

comments powered by Disqus
This page was last updated almost 3 years ago.