DEV Community

Cover image for How I Built an Interactive Asteroid Dashboard with NASA's Data
Arjun Vijay Prakash
Arjun Vijay Prakash Subscriber

Posted on

How I Built an Interactive Asteroid Dashboard with NASA's Data

I was scrolling through Instagram the other day and stumbled on a reel.

The creator was listing "APIs you shouldn't miss," and the very first one? NASA.

I paused. NASA. Space. Data.
That was enough to pull me down a rabbit hole.

I dug into their NeoWs API and before I knew it, I had an idea: why not make a dashboard that tracks near-Earth asteroids, highlights risks, and makes sense of all this space data?

What started as a casual scrolling session turned into a full-on data science and analysis project.

Check out the project for yourself: https://astroscope.streamlit.app/
GitHub repository: https://github.com/ArjunCodess/astroscope

Here is a quick demo of the dashboard:

Some screenshots:

Image

Image

Image Image

Breaking It Down

Step 1: Planning What I Wanted

Before writing a single line of code, I had to figure out what this project should actually do:

  • Fetch real asteroid data from NASA.
  • Show size, speed, and how close each asteroid comes to Earth.
  • Highlight which asteroids might be risky.
  • Visualise everything in charts and tables, not walls of JSON.
  • Make it smooth enough to work on both desktop and mobile.

That gave me a blueprint for tools, features, and project structure.


Step 2: Pulling Data from NASA's NeoWs API

NeoWs is powerful, but it has limits.
You can only fetch up to 7 days of data at a time.

So I had to:

  • Break the total range (like 30 days) into 7-day chunks.
  • Call the API for each chunk sequentially.
  • Save all the results locally so I wouldn't keep hammering NASA’s servers.

This was all handled in data_fetcher.py using Python's requests library.
I added retries and error handling because API calls fail, always.


Step 3: Cleaning Up NASA’s Raw Data

NASA sends massive JSON files, and most of it is noise.
I needed only the essentials:

  • ID, name, size
  • Approach date
  • Velocity
  • Miss distance
  • Hazard flag

I wrote data_processing.py to flatten everything into neat tables. pandas handled the heavy lifting.
I also converted units (like velocity into km/h) and saved the cleaned data as CSVs for faster loading later.


Step 4: Making Sense of It

Once the data was clean, I wanted to give it meaning. In analysis.py, I built a risk scoring system:

  • A risk score combining size, speed, and distance.
  • A threshold (0.6 by default) for high-risk asteroids.
  • Time series to show how risk changes over days.
  • Rankings for “closest approach” days.

This let me highlight outliers, giant rocks flying closer than usual.
pandas made all of this easy.


Step 5: Building the Dashboard

I used Streamlit because it lets you build web apps in Python without the headache of traditional frameworks.

Here’s what I added:

  • Date picker and risk slider for filtering.
  • GitHub-style heatmap showing average daily risk scores (brighter = scarier).
  • Top-10 closest approaches table with details.
  • Charts for asteroid sizes, speeds, and risk distributions.
  • Responsive layout for phones and laptops.

I also used plotly to make the graphs interactive and visually appealing.


Step 6: Configuration and Setup

I kept the app flexible with a .env file:

NASA_API_KEY=""
DATA_FETCH_DAYS=30
DATA_DIR="data"
API_CHUNK_SIZE=7
RISK_THRESHOLD=0.6
Enter fullscreen mode Exit fullscreen mode

This keeps sensitive info like the API key safe and allows easy changes to the project's parameters.


Step 7: Putting Everything Together

When you run the app:

  1. It checks if the data for the chosen days is already saved.
  2. If not, it fetches it from NASA.
  3. Then it processes and analyses the data.
  4. Finally, it serves the dashboard.

I also made it possible to run individual steps separately for debugging and testing.

Here's a high-level flow of how the app works:

Image


Final Thoughts

It's crazy how a 15-second reel led me to a full-fledged data project.

This dashboard is my little window to the space.
It's not perfect, but it works, it's extendable, and it's fun to explore.

If you're a coder or just a space nerd, try building your own.
Start small, play with real data, then push it further.
The universe is massive, unpredictable, and full of surprises.

Thanks for reading!

Top comments (24)

Collapse
 
gamelord2011 profile image
Reid Burton

You know, jpl (NASA's Jet Prupoltion Labrotory) has an OLD e-mail api for querying spaceship positions.

Collapse
 
dbugshe2 profile image
maroof shittu

That sounds fascinating, now that I'm aware this was ever a thing, it's time to dive into another rabbit hole

Collapse
 
gamelord2011 profile image
Reid Burton

Like, you have to manually put in the email to send the response to as part of the query.

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash

Whoa, that's wild. 😅
Email as an api input sounds super old.

Got a link or doc for that?
Would love to see it.

Thread Thread
 
gamelord2011 profile image
Reid Burton

Check ssd.jpl.nasa.gov/horizons, under email interface.

Thread Thread
 
gamelord2011 profile image
Reid Burton

This is one of the things from the page that I didn't read until just now:

However, e-mail requests may now be most practical for those working in a UNIX/Linux/MacOS programmatic command-line and text editor environment.

Thread Thread
 
arjuncodess profile image
Arjun Vijay Prakash

Makes sense. Back then, Unix heads probably lived inside terminals anyway, so email queries weren't even weird, different era.

Collapse
 
bradtaniguchi profile image
Brad

I used this API years back for a college project (its bad, but out there still lol)

NASA has a number of other free APIs you can use as well, but the NEO one is the most interesting when it comes to understanding data, and the general idea there's giant rocks flying overhead lol.

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash • Edited

Hey, that's nice. Would love to see your project too.

Lol, but yup, that's true.

I'm currently exploring these in deep to see if I can make something more out of them. I really do love the space and cosmos.

Collapse
 
imjyotiraditya profile image
Jyotiraditya Panda

Pretty cool project. I messed around with NASA’s API a while back just to pull some asteroid data into a simple script, but I never took it further than printing out numbers in the terminal. Seeing how you built a full dashboard around it makes me realize how much more useful (and fun) it is when you can actually see the info plotted out. Might try something similar myself with charts or live graphs next time I dive into it.

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash

Yeah exactly! Raw data feels dead until you see it. Definitely try it. 👀

Collapse
 
rohan_sharma profile image
Rohan Sharma

THIS IS COOL!

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash

Thanks a lot, RS!

Collapse
 
salman_ansari_8fc02f34420 profile image
Salman Ansari

COOL MAN!! I would love to see you like make a asteroid mineral Content or something like that

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash

More stuff coming soon! I'm not yet done with this. They did a really great thing by making these APIs public & free.

Collapse
 
salman_ansari_8fc02f34420 profile image
Salman Ansari

So you are saying even I can build stuff using their API

Thread Thread
 
arjuncodess profile image
Arjun Vijay Prakash

Yeah, exactly! Anyone can. Would love to see what you build.

Collapse
 
voidbass profile image
voidbass

Streamlit + Plotly is perfect for this.

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash

Exactly! It makes it so simple.

Collapse
 
k0msenapati profile image
K Om Senapati

Good job

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash

Really appreciate it, thank you!

Collapse
 
claryjia profile image
Clary

Super Impressive!

Collapse
 
arjuncodess profile image
Arjun Vijay Prakash

Thanks so much! Means a lot.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.