Advertisement
Mori007

usingpython_api

Feb 17th, 2021
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. import json
  2. import requests
  3.  
  4. # requesting the API NASA
  5. apod_api_request = requests.get("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY")
  6.  
  7. # Parsing data json
  8. apod = apod_api_request.json()
  9.  
  10. # print(apod)
  11.  
  12. # Display the data
  13. print(f"Copyright: {apod['copyright']}")
  14. print(f"Date     : {apod['date']}")
  15. print(f"Explain  : {apod['explanation']}")
  16. print(f"HURL     : {apod['hdurl']}")
  17. print(f"Media    : {apod['media_type']}")
  18. print(f"Title    : {apod['title']}")
  19. print(f"URL      : {apod['url']}")
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement