Realtime International Space Station API with AngularJS

It’s my first week at Pusher and, intrigued by Pusher’s realtime Reddit feed, I wanted to have a go at making my first Websockets API. Being a huge fan of AngularJS, I also wanted to see for myself how simple it is to make the framework realtime with Pusher’s new Angular library.

NASA, with space always being one of my great fascinations, seemed a natural place to turn to. Upon visiting NASA’s data bank, I found that had crunched NASA’s raw International Space Station location data into a JSON API. Perfect, I thought, as it would be a chance to get some frequently updated data and stream it with the power of Websockets.

Using The API With AngularJS

Firstly, we need to include AngularJS, Pusher, and Pusher-Angular within our HTML file.

<!-- AngularJS -->
<script src=""></script>

<!-- pusher-js -->
<script src="//"></script>

<!-- pusher-angular -->
<script src="//"></script>

Now in our javascript we need to set up an Angular application and controller.

// Include 'pusher-angular' as a dependency
angular.module('MyApp', ['pusher-angular'] )

// Then inject the $pusher service into your controller

.controller('MyCtrl', ['$scope', '$pusher', function($scope, $pusher){
  // code goes here...

Within our controller, setting up our Pusher client to talk to the API should be fairly straightforward. Simply instantiate a new Pusher object (with the key for the ISS API), and pass it into the $pusher service.

var client = new Pusher('fa15651bc1ad6c916fc7');
var pusher = $pusher(client);

Now let’s have our Pusher client subscribe to the International Space Station channel:

var issChannel = pusher.subscribe('iss-channel');

Now we can log out the data from the ‘new-location’ event triggered by the API in realtime:

issChannel.bind('new-location', function(iss){

In the console, this will print out:


And there you have it: a live feed of the whereabouts of the International Space Station using Pusher and AngularJS.

Try The Demo And Build Something!

Check out Where Is The ISS? to have a peek at the demo. It tracks the coordinates of the International Space Station on a map, while below you can see NASA’s live stream of shots taken by cameras on the exterior of the station.

Heroku GIF

Feel more than free to make your own application with this API and let us know when you have. We’d love to see what more you can do with it!

If you’re an Angular-lover and are thinking of combining it with Pusher, head on over to the Pusher-Angular Github Page to find more ways to power your app with realtime.

Ready to begin?

Start building your realtime experience today.

From in-app chat to realtime graphs and location tracking, you can rely on Pusher to scale to million of users and trillions of messages