Skip to content
/ NeoRest Public

A simple rest service built on node JS using express

Notifications You must be signed in to change notification settings

bikos/NeoRest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API to Fetch Near Earth Objects

Requirements

Installation

  • git clone https://github.com/bikos/NeoRest.git
  • cd NeoRest
  • npm install
  • npm start
  • optional: include .env in your .gitignore

Default key is Demo Key and it works. If you have API Key from NASA replace the default key in .env file.

For Unit Test

  • npm test

Testing Post Request

POST /neoInfo
Content-Type: application/json
{
  "dateStart": <START_ISO_DATE>,
  "dateEnd": <END_ISO_DATE>,
  "within": {
  "value": <DISTANCE>,
  "units": <UNIT> 
  }
}
Parameter Type Required? Description
START_ISO_DATE string required Start Date in ISO Format ( YYYY-MM-DD)
END_ISO_DATE string required End Date in ISO Format (YYYY-MM-DD)
DISTANCE number required Distance from Earth in which NEO might be found
UNIT string required SI unit of distance, use kilometers
A template for making POST request is included in the project.

- In Vscode install REST Client
- Open the test.http file inside the src folder
- Click on 'Send Request'
- See the response in adjacent screen.

Response of a successful request

{
  "asteroids": [
    {
      "name": "433 Eros (A898 PA)",
      "date": "2012-01-31",
      "distance": 26729521.135077033
    },
    {
      "name": "433 Eros (A898 PA)",
      "date": "2019-01-15",
      "distance": 31205919.274956476
    },
    {
      "name": "1566 Icarus (1949 MA)",
      "date": "2015-06-16",
      "distance": 8053781.761441007
    }]
 }   
Parameter Type Description
asteroids list List of asteroids
name string Name of the asteroid
date string ISO date the object was closest to earth
distance number Distance between the asteroid and earth in Kilometers

Please note the format of the JSON object and the header being sent as follows:

Screen Shot 2022-09-05 at 11 10 24 AM

About

A simple rest service built on node JS using express

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published