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:
![]() |
![]() |
---|
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
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:
- It checks if the data for the chosen days is already saved.
- If not, it fetches it from NASA.
- Then it processes and analyses the data.
- 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:
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)
You know, jpl (NASA's Jet Prupoltion Labrotory) has an OLD e-mail api for querying spaceship positions.
That sounds fascinating, now that I'm aware this was ever a thing, it's time to dive into another rabbit hole
Like, you have to manually put in the email to send the response to as part of the query.
Whoa, that's wild. 😅
Email as an api input sounds super old.
Got a link or doc for that?
Would love to see it.
Check ssd.jpl.nasa.gov/horizons, under email interface.
This is one of the things from the page that I didn't read until just now:
Makes sense. Back then, Unix heads probably lived inside terminals anyway, so email queries weren't even weird, different era.
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.
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.
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.
Yeah exactly! Raw data feels dead until you see it. Definitely try it. 👀
THIS IS COOL!
Thanks a lot, RS!
COOL MAN!! I would love to see you like make a asteroid mineral Content or something like that
More stuff coming soon! I'm not yet done with this. They did a really great thing by making these APIs public & free.
So you are saying even I can build stuff using their API
Yeah, exactly! Anyone can. Would love to see what you build.
Streamlit + Plotly is perfect for this.
Exactly! It makes it so simple.
Good job
Really appreciate it, thank you!
Super Impressive!
Thanks so much! Means a lot.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.