Mars Rover Photos
Mars-photos API will provide access to photos taken by Rover vehicle at Mars everyday. If you’d like to use this service on an ongoing basis you can get an API key for free here.
Here is a simply code that uses requests, json and webbrowser libraries.
import requests
import json
import webbrowser
def rover():
params = {"earth_date":"2016-10-17", "api_key":"DEMO_KEY"}
f = r"https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?"
data = requests.get(f, params = params)
a = json.loads(data.text)
for i in a["photos"]:
print(i, "\n\n\n")
b = a["photos"][3]["img_src"]
print(a["photos"][1]["img_src"])
webbrowser.open(b)
rover()
If you need a refresher on user defined functions lesson in Python here is a link to our Defining Functions Lesson.
Source of API: Nasa API Webpage
Source: Nasa