Demo Application

Look at how to integrate the NASA APIs in a Django application.

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
...