The NASA Projects API allows you to dynamically view a subset of missions undertaken by NASA detailing the mission description, planets visited, and the mission dates/duration.
- GitHub Link: https://github.com/Jagerziel/NASA_Project_API
- Railway Link: https://nasaprojectapi-production.up.railway.app/api/
- API Root Directory: http://localhost:4000/api/
- The API is sourced from https://api.nasa.gov/
For convenience, links have been provided to navigate to either all projects or a table of contents where you can select projects individually.
To get started, navigate to the root path or insert one of the following paths into your browser:
- Root Path: http://localhost:4000/api/
- Projects: http://localhost:4000/api/projects/
- Projects by ID: http://localhost:4000/api/projects/:id/
Data is produced by project IDs which contain a project object containing all the relevent data. The data pulled using item 1 to produce a cleaner version of item 2
- Project ID
- Project Details
Note: Data is limited to the first 100 entries for this project
- cors
- dotenv
- express
- node-fetch
- nodemon
- morgan
- mongoose
- Obtain Project IDs
- Write Project IDs to ProjectID File
- Use ProjectID File to dynamically pull individual projects
- Cleanse and model project data
Fetch IDs from the API and write to JSON file. Snippet of object output:
[{"projectId":116443,"lastUpdated":"2022-12-16"},{"projectId":94824,"lastUpdated":"2022-12-9"},...]
Use fetched IDs to write file of JSON objects. The data needed to be cleansed as follows:
- The output provides data in the following format - the first step is to go into the project object value:
{
Project: {Object}
ID: Number
}
- After removing the first layer, the data was modeled to include only the following:
const dataNASA = new Schema({
projectId: { type: Number },
title: { type: String },
benefits: { type: String },
description: { type: String },
destinations: [ { type: Object } ],
startYear: { type: Number },
startMonth: { type: Number },
endYear: { type: Number },
endMonth: { type: Number }
})
- The NASA data in the subset pulled null values so of the 100 entries pulled, 80 were valid and should be kept. This was filtered in the seed file:
const scrubbedData = data.filter((notNull)=>{
return notNull !== null
})
- With the null entries removed, the next cleansing was conducted on the destinations. The destinations is embedded as an array of objects. In the seed file, each object is replaced with a smaller object only containing the desired fields:
for (let j = 0; j < scrubbedData.length; j++) {
const exists = 'destinations' in scrubbedData[j]
if (exists) {
scrubbedData[j].destinations = scrubbedData[j].destinations.map(item => {
item = {
lkuCodeId : item.lkuCodeId,
description : item.description
}
return item
})
}
}
- User Authentication
- HTML Interface/Structured Data Output
- Add writable project/entries for Future Projects