get a Nasa api key by clicking here.
- import the file
import apod_object_parser- Now call the
get_datafunction and pass thenasa api keyas the argument. Note api_key is a string. The response returned will be a Dictionary. Now you can parse the dictionary too
response = apod_object_parser.get_data(##Pass In Your API key here)the get_date function takes the dictionary we got above and returns the date.
date = apod_object_parser.get_date(response)the get_explaination function takes the dictionary we got above and returns the explaintion.
date = apod_object_parser.get_explaination(response)the get_hdurl function takes the dictionary we got above and returns the High Definition url of the image.
date = apod_object_parser.get_hdurl(response)the get_title function takes the dictionary we got above and returns the title of the image.
date = apod_object_parser.get_title(response)the get_url function takes the dictionary we got above and returns the Standard definition url of the image.
date = apod_object_parser.get_hdurl(response)the get_media_type function takes the dictionary we got above and returns the media type the file (might be a video of a image).
date = apod_object_parser.get_hdurl(response)there are also other functions that might help you in situations
the download_image finction takes the url (hdurl or url) and the date from the function get_date and downloads the image in the current directory and with the file name of the date. the image downloaded is in the .jpg format
apod_object_parser.download_image(url, date)sometimes the image we downloaded above might not be in the right format (.jpg) so you may call convert_image function to convert the image into .png. takes the image_path parameter which is the filepath.
apod_object_parser.convert_image(image_path)