In the following project NASA's astronomical data about celestial bodies moving near the Earth's orbit will be used. The API is called Neo, which is an abbreviation for Near Earth Objects.
⋅ python package requests
$ pip install requests
Since the data is not updated very often, the call of the API is cached for 3 days. The mechanism is set so that if a local file exists in the data folder, it will be loaded if the data is not older than 30 days. Otherwise the data will be loaded from the API and stored in a file with the timestamp as postfix until when the data is valid.
Get a API Key
Go to https://api.nasa.gov/
Signup for a API-Key and enter your data in the form
⋅ First Name ⋅ Last Name ⋅ Email
As a response you'll see the following message:
Your API key for <E-Mail> is: <API-KEY> You can start using this key to make web service requests. Simply pass your key in the URL when making a web request. Here's an example: https://api.nasa.gov/planetary/apod?api_key=<API-KEY> For additional support, please contact us (email@example.com). When contacting us, please tell us what API you're accessing and provide the following account details so we can quickly find you: Account Email: <E-MAIL> Account ID: <ACCOUNT-ID>
You will also receive the information by e-mail.
The API only returns the data for the last seven days from the start date.
⋅ Open App.py and run it