Location of the ISS
Learn to Program, Third Edition — by Chris Pine (77 / 116)
👈 Trivia Database | TOC | Where Did I Put My Keys? 👉
Now you’re going to use an API to find the position of the International Space Station (ISS) and then plot where it currently is using Google Maps.
First, check out the beautiful documentation for the ISS Current Location API.[4] You can see the JSON endpoint,[5] and the structure of the response is clearly laid out:
{
"message": "success",
"timestamp": UNIX_TIME_STAMP,
"iss_position": {
"latitude": CURRENT_LATITUDE,
"longitude": CURRENT_LONGITUDE
}
}
The Google Maps API is much trickier to use. Rather than using the actual, official API, I poked around and found that the following URL will open a map with a marker at location “40, 10” (latitude and longitude), centered at that same location, and zoomed all the way out:
https://www.google.com/maps?q=40,10&ll=40,10&z=1
That should work well enough for us. Let’s have a look at this URL: it starts with the protocol (https://), then continues with the domain (www.google.com), is followed by the path (/maps), and ends with a parameter list (?q=40,10&ll=40,10&z=1). (It’s common to pass in information to APIs via the URL parameter list, as you did with the Open Trivia Database API Mayonnaise Fiasco. Did you actually request that? I can’t believe you sometimes.)