Accessing Data

Use urllib.request.urlopen() function inorder to open the API url and json.loads(.read()) function to read the data from the url.

Python3




import json 
import turtle
import urllib.request
import time
import webbrowser
import geocoder
 
url = "http://api.open-notify.org/astros.json"
response = urllib.request.urlopen(url)
result = json.loads(response.read())
result


Output:

{'people': [{'name': 'Mark Vande Hei', 'craft': 'ISS'},
  {'name': 'Oleg Novitskiy', 'craft': 'ISS'},
  {'name': 'Pyotr Dubrov', 'craft': 'ISS'},
  {'name': 'Thomas Pesquet', 'craft': 'ISS'},
  {'name': 'Megan McArthur', 'craft': 'ISS'},
  {'name': 'Shane Kimbrough', 'craft': 'ISS'},
  {'name': 'Akihiko Hoshide', 'craft': 'ISS'},
  {'name': 'Nie Haisheng', 'craft': 'Tiangong'},
  {'name': 'Liu Boming', 'craft': 'Tiangong'},
  {'name': 'Tang Hongbo', 'craft': 'Tiangong'}],
 'number': 10,
 'message': 'success'}

Create.txt file for astronauts info: Create iss.text file using an open() function in write mode and write the result(names & numbers of astronauts) as data inside the file.

Python3




file = open("iss.txt", "w")
file.write(
  "There are currently " + str(result["number"]) +
  " astronauts on the ISS: \n\n")
 
people = result["people"]
for p in people:
    file.write(p['name'] + " - on board" + "\n")


How To Track ISS (International Space Station) Using Python?

In this article, we will discuss how to track the current location of ISS(International Space Station) and then maps the location. We will write a script that will display the current location of ISS along with onboarded crew names. It works on API, it takes the current location of ISS in the form of latitude and longitude and then locates that value onto the map. It takes the value from the website at every 5 sec and then updates the value of latitude and longitude and thus also moves the ISS icon on the world map. The movement visible is very little but you can notice that movement in the gif below. This is possible by using some of the modules of python like JSON, urllib.requests, Webbrowser, Geocoder etc. Numerous functions are used to create this script. 

Similar Reads

Modules Needed:

JSON: It is JavaScript Object Notation, python supports JSON through a built-in package called JSON. It is just similar to the dictionary in python. To use the functions of this module, import the JSON module into the script....

Getting Started

So now there is a problem with tracking ISS because it travels at a speed of almost 28000km/h. Thus, it takes only 90 minutes to complete 1 rotation around the earth. At such a speed, it becomes quite difficult to lock the exact coordinates. So here comes the API to solve this issue. API acts as an intermediate between the website and the program, thus providing the current time data for the program....

Accessing Data:

Use urllib.request.urlopen() function inorder to open the API url and json.loads(.read()) function to read the data from the url....

Current Latitude & Longitude of User:

...

Setting Up The World Map:

...

Contact Us