International Space Station

node v14.20.1
version: 0.1.0
endpointsharetweet
http://open-notify.org/ takes raw data from NASA and turns it into APIs related to space and spacecraft. We've wrapped these up into convenient function at the end of the document, but you can see their result here. Let's start by seeing where the ISS is right now:
require("request") await currentPosition();
// Change this to use your location in this example require('@runkit/killshot13/614ee947836e1a0008e1a10e/master') let myLocation = "Crestview, FL"; await nextPass(myLocation);
And how many are in space?
await numberInSpace();
Which are:
var people = await peopleInSpace(); people.map(function(person) { return person.name + " (" + person.craft + ")"; });
Get the current position of the ISS.
async function currentPosition() { return JSON.parse(await require("request-promise")("http://api.open-notify.org/iss-now.json")).iss_position; };
Find out when the ISS will next be above you.
async function nextPass(location) { var geocode = require('notebook')('capicue/geocode/5.0.0'); return geocode.simpleLookup(location).then(function(coordinates) { var options = {lat: coordinates.lat, lon: coordinates.lng}; return require("request-promise")('http://api.open-notify.org/iss-pass.json', { qs: options }); }).then(function(passResult) { var timestamp = JSON.parse(passResult).response[0].risetime; return require("moment").unix(timestamp).fromNow(); }); };
Find out how many people are currently in space.
async function numberInSpace() { return JSON.parse(await require("request-promise")('http://api.open-notify.org/astros.json')).number; };
Then find out who they are.
async function peopleInSpace() { return JSON.parse(await require("request-promise")("http://api.open-notify.org/astros.json")).people; };
module.exports = { currentPosition: currentPosition, nextPass: nextPass, numberInSpace: numberInSpace, peopleInSpace: peopleInSpace };
Loading…

no comments

    sign in to comment