API Examples

Current ISS Location

The International Space Station is moving at close to 28,000 km/h so its location changes really fast! Where is it right now?

Documentation: ISS Location Now

Example:

Using leaflet and jquery one can write a script to show the current location of the ISS and update it every 5 seconds:

function moveISS () {
    $.getJSON('http://api.open-notify.org/iss-now.json?callback=?', function(data) {
        var lat = data['iss_position']['latitude'];
        var lon = data['iss_position']['longitude'];

        // See leaflet docs for setting up icons and map layers
        // The update to the map is done here:
        iss.setLatLng([lat, lon]);
        isscirc.setLatLng([lat, lon]);
        map.panTo([lat, lon], animate=true);
    });
    setTimeout(moveISS, 5000); 
}

ISS Pass Times

The API returns a list of upcoming ISS passes for a particular location formatted as JSON.

Documentation: ISS Pass Predictions

Example:

Five upcoming ISS passes for Portland Oregon:

Using jquery:

$.getJSON('http://api.open-notify.org/iss-pass.json?lat=45.0&lon=-122.3&alt=20&n=5&callback=?', function(data) {
    data['response'].forEach(function (d) {
        var date = new Date(d['risetime']*1000);
         $('#isspass').append('<li>' + date.toString() + '</li>');
    });
});

Number of People In Space

How many people are in space right now?

Documentation: Number of People In Space

Example:

There are currently ? humans in space. They are:

Using jquery:

$.getJSON('http://api.open-notify.org/astros.json?callback=?', function(data) {
    var number = data['number'];
    $('#spacepeeps').html(number);

    data['people'].forEach(function (d) {
         $('#astronames').append('<li>' + d['name'] + '</li>');
    });
});