Secrets

Handling an API call to a restricted endpoint from nasa.gov

API

I wanted to find a way to play around with the API from nasa.gov and stumbled upon this cool feature where if you register on their website and with an access token generated by them you can actually see in real time the latest pictures taken by Mars Rover. You can find here one of the latest 100 pictures.

Bonus: here is one of the latest photos of Earth collected by DSCOVR's Earth Polychromatic Imaging Camera (EPIC) instrument. Uniquely positioned at the Earth-Sun Lagrange point, EPIC provides full disc imagery of the Earth and captures unique perspectives of certain astronomical events such as lunar transits using a 2048x2048 pixel CCD (Charge Coupled Device) detector coupled to a 30-cm aperture Cassegrain telescope..

If you want to do this yourself head on to api.nasa.gov . Signup to get your own API key. And follow the API Docs for any of the public APIs available.

Also if you want to see the logic in the code of how I implemented it.

Then you have to resolve the promise to get the data to be rendered

And at the end you inject it inside your html.

You can see more tricks like this in my blog at blog.martioli.com .

Developed with love by Adrian Maciuc © 2023

To Top