When can I next see the ISS (requires UK postcode)?

A single flow that provides a simple HTTP JSON API for requesting the next overhead pass of the International Space Station (ISS) based on a valid UK postcode.

API description

Once the flow is deployed an /iss HTTP endpoint will be created taking a single query parameter postcode=xxxxxxx.

Example of an HTTP GET request against the API:

<hostname>:<port>/iss?postcode=SO212JN

A HTTP GET request against the API will return:

Output field Field Description Example of format
message Request status "success"
time UTC timestamp of next ISS pass 1570706118
strtime Formatted version of time "10/10/2019, 11:15:18 AM UTC"
duration Duration (seconds) of next ISS pass 559
strduration Formatted version of duration "9 minutes 19 seconds"
[{"id":"8981a3df.74d82","type":"tab","label":"When can I see the ISS?","disabled":false,"info":""},{"id":"91bf0ac4.22ea9","type":"http request","z":"8981a3df.74d82","name":"Convert UK postcode","method":"GET","ret":"obj","paytoqs":false,"url":"api.postcodes.io/postcodes/{{{postcode}}}","tls":"","persist":false,"proxy":"","authType":"","x":260,"y":280,"wires":[["b62a5e8e.1f70b8","f61b5d3a.9bda1"]]},{"id":"3ca18412.522c14","type":"change","z":"8981a3df.74d82","name":"","rules":[{"t":"set","p":"postcode","pt":"msg","to":"req.query.postcode","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":200,"wires":[["91bf0ac4.22ea9"]]},{"id":"abd1f71.68be908","type":"change","z":"8981a3df.74d82","name":"","rules":[{"t":"set","p":"longitude","pt":"msg","to":"payload.result.longitude","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":100,"wires":[["d5acbf94.5b1ac8"]]},{"id":"d5acbf94.5b1ac8","type":"change","z":"8981a3df.74d82","name":"","rules":[{"t":"set","p":"latitude","pt":"msg","to":"payload.result.latitude","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":160,"wires":[["842507d0.1e9bc8"]]},{"id":"842507d0.1e9bc8","type":"http request","z":"8981a3df.74d82","name":"Request next ISS pass","method":"GET","ret":"obj","paytoqs":false,"url":"http://api.open-notify.org/iss-pass.json?lat={{latitude}}&lon={{longitude}}","tls":"","persist":false,"proxy":"","authType":"","x":640,"y":220,"wires":[["6fda684.f4e7398"]]},{"id":"f7adf79f.56fc18","type":"http in","z":"8981a3df.74d82","name":"When will the ISS be visible next?","url":"iss","method":"get","upload":false,"swaggerDoc":"","x":150,"y":120,"wires":[["3ca18412.522c14"]]},{"id":"dc8d5e10.f8a678","type":"http response","z":"8981a3df.74d82","name":"Respond to request","statusCode":"","headers":{},"x":720,"y":340,"wires":[]},{"id":"b62a5e8e.1f70b8","type":"switch","z":"8981a3df.74d82","name":"Good postcode found","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":520,"y":40,"wires":[["abd1f71.68be908"]]},{"id":"f61b5d3a.9bda1","type":"switch","z":"8981a3df.74d82","name":"Bad postcode or failure","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":530,"y":460,"wires":[["992d0deb.d3f55"]]},{"id":"992d0deb.d3f55","type":"http response","z":"8981a3df.74d82","name":"Failed to find postcode","statusCode":"404","headers":{},"x":550,"y":520,"wires":[]},{"id":"6fda684.f4e7398","type":"function","z":"8981a3df.74d82","name":"Prepare output","func":"// Gather details from the next ISS pass\n// over user-specified location.\nduration     = msg.payload.response[0].duration;\nrisetime     = msg.payload.response[0].risetime;\nstrTime      = new Date(risetime*1000).toLocaleString('en-GB', { timeZone: 'UTC', timeZoneName: 'short' });\ndateDuration = new Date(duration*1000);\nstrDuration  = dateDuration.getMinutes()\n               + \" minutes \"\n               + dateDuration.getSeconds()\n               + \" seconds\";\n\n// Delete previous request details\ndelete msg.payload.request;\ndelete msg.payload.response;\n\n// Create output details\nmsg.payload.time        = risetime;\nmsg.payload.strtime     = strTime;\nmsg.payload.duration    = duration; \nmsg.payload.strduration = strDuration;\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":280,"wires":[["dc8d5e10.f8a678"]]}]

Flow Info

Created 6 years ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x3)
  • function (x1)
  • http in (x1)
  • http request (x2)
  • http response (x2)
  • switch (x2)
Other
  • tab (x1)

Tags

  • iss
  • postcode
  • uk
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option