未验证 提交 27f24651 编写于 作者: J Jaydeep Das 提交者: GitHub

Added new file: nasa_data.py (#5543)

* Added new file: nasa_data.py

* Modified as per review

* Minor change

* print(get_archive_data("apollo 2011")["collection"]["items"][0]["data"][0]["description"])

* Update nasa_data.py
Co-authored-by: NChristian Clauss <cclauss@me.com>
上级 c50f0c56
import requests
def get_apod_data(api_key: str) -> dict:
"""
Get the APOD(Astronomical Picture of the day) data
Get the API Key from : https://api.nasa.gov/
"""
url = "https://api.nasa.gov/planetary/apod/"
return requests.get(url, params={"api_key": api_key}).json()
def get_archive_data(query: str) -> dict:
"""
Get the data of a particular query from NASA archives
"""
endpoint = "https://images-api.nasa.gov/search"
return requests.get(endpoint, params={"q": query}).json()
if __name__ == "__main__":
print(get_apod_data("YOUR API KEY"))
print(
get_archive_data("apollo 2011")["collection"]["items"][0]["data"][0][
"description"
]
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册