Search⌘ K
AI Features

Demo Application

Explore how to integrate multiple NASA APIs into a Django application to retrieve and display real-time astronomy pictures, near-Earth asteroid data, Earth events, and Mars rover images. Understand how each API is called and how data is rendered on different application pages, enabling you to build a functional space-focused web app.

We'll cover the following...

Now that we've understood NASA APIs, we can use these APIs in an actual application.

Resources used

We'll use the following NASA APIs in our application:

  • Asteroids NeoWs
  • EONET
  • Mars Rover Photos
  • APOD

Our Django application

The widget below contains the code for our application. Click the "Run" button to run the application. Once the server starts, click the link at the end of the widget to go to the application.

"""
ASGI config for demo project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')

application = get_asgi_application()
Run the demo app

Let's look at the code in views.py file where the APIs are being called:

  • Lines 8–17: We define the index() function, which is used to render Astronomy Picture of the Day on the application's homepage.
    • Line 13: We call the endpoint
...