Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mariolazzari/nasa-api

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mariolazzari/nasa-api

NASA public REST API client

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Nasa Open API client


This package is a TypeScript based wrapper around the public NASA REST APIs.

Prerequisites

In order to use this package, you need an api key: You can read more on how to obtain the API key on this page.

This package requires NodeJS (version 18 or later) and a node package manager (Npm, Yarn, Pnpm or Bun).

To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
v10.1.0
v18.18.0

Gettting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.


Installation

BEFORE YOU INSTALL: please read the prerequisites.

Start with cloning this repo on your local machine:

$ git clone https://github.com/mariolazzari/nasa-api.git
$ cd nasa

To install and set up the library, run:

npm install @mariolazzari/nasa-api

Usage

Import package

import { Nasa } from "@mariolazzari/nasa-api"

Watch mode

npm test

Unit testing

npm test

Bulding new version

npm build

This task will create a distribution version of the project inside your local dist/ folder


Nasa class

Nasa class content handles all the requests and the responses to the three main Rijks museum REST APIs.

Constructor

In order to initialize Nasa client:

const nasa = new Nasa(NASA_API_KEY)

Constructor parameters

ParameterTypeRequiredDefault
apiKeystringYes

Methods

Nasa client includes the following three methods:

apodDate

Description

This asynchronous method handles GET /planetary/apod REST API, in order to return the astronomical picture of the day for selected day (current day by default).

Prototype

async apodDate(date: Date = new Date()): Promise<Result<Apod>> 

Sample code

const date = new Date(2023, 2, 28);
const apod: Result<Apod> = await nasa.apodDate(date);
apodDates

Description

This asynchronous method handles GET /planetary/apod REST API, in order to return the astronomical pictures of the day for selected date range.

Prototype

async apodDates(from: Date = new Date(), to: Date = new Date()): Promise<Result<Apod[]>> 

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const apods: Result<Apod[]> = await nasa.apodDates(from, to);
apodRandom

Description

This asynchronous method handles GET /planetary/apod REST API, in order to return n random astronomical pictures of the day (10 pictures by default).

Prototype

async apodRandom(n:number = 10): Promise<Result<Apod[]>> 

Sample code

const apods: Result<Apod[]> = await nasa.apodRandom(10);
neoFeed

Description

This asynchronous method handles GET /neo/rest/v1/feed REST API, in order to return the near Earth objects for selected dates range.

Prototype

async neoFeed(from: Date, to: Date): Promise<Result<NeoResponse>> 

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const neos: Result<NeoResponse> = await nasa.neoFeed(from, to);
neoLookup

Description

This asynchronous method handles GET /neo/rest/v1/neo/:id REST API, in order to return the near Earth objects for selected asteroid ID, including its orbital data.

Prototype

async neolookup(asteroidId:number): Promise<Result<Neo & Link>> 

Sample code

const asteroidId = 3542519
const neo: Result<Neo & Link> = await nasa.neoLookup(asteroidId);
donkiCme

Description

This asynchronous method handles GET /DONKI/CME REST API, in order to return the coronal mass ejection (CME) for selected dates range.

Prototype

async donkiCme(from: Date, to: Date): Promise<Result<CoronalMassEjection[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const cme: Result<CoronalMassEjection[]> = await nasa.donkiCme(from, to);
donkiCmeAnalysis

Description

This asynchronous method handles GET /DONKI/CMEAnalysis REST API, in order to return the coronal mass ejection (CME) analysis for selected dates range.

Prototype

async donkiCme(from: Date, to: Date, mostAccurateOnly: boolean, completeEntryOnly: boolean, speed:number ): Promise<Result<CoronalMassEjectionAnalysis[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday
mostAccurateOnlybooleanNotrue
completeEntryOnlybooleanNotrue
speednumberNo0

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const cmeAnalysis: Result<CoronalMassEjectionAnalysis>[] = await nasa.donkiCmeAnalysis(from, to);
donkiGst

Description

This asynchronous method handles GET /DONKI/GST REST API, in order to return the Geomagnetic Storm (GST) for selected dates range.

Prototype

async donkiGst(from: Date, to: Date ): Promise<Result<GeomagneticStorm[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const gst: Result<GeomagneticStorm[]> = await nasa.donkiCme(from, to);
donkiIps

Description

This asynchronous method handles GET /DONKI/IPS REST API, in order to return the Interplanetary Shock (IPS) for selected dates range.

Prototype

async donkiIps(from: Date, to: Date ): Promise<Result<InterplanetaryShock[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const ips: Result<InterplanetaryShock[]> = await nasa.donkiIps(from, to);
donkiFlr

Description

This asynchronous method handles GET /DONKI/FLR REST API, in order to return the Solar Flare (FLR) for selected dates range.

Prototype

async donkiFlr(from: Date, to: Date ): Promise<Result<SolarFlare[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const ips: Result<SolarFlare[]> = await nasa.donkiIps(from, to);
donkiSep

Description

This asynchronous method handles GET /DONKI/SEP REST API, in order to return the Solar Energetic Particle (SEP) for selected dates range.

Prototype

async donkiSep(from: Date, to: Date ): Promise<Result<SolarEnergeticParticle[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const sep: Result<SolarEnergeticParticle[]> = await nasa.donkiSep(from, to);
donkiMpc

Description

This asynchronous method handles GET /DONKI/MPC REST API, in order to return the Magnetopause Crossing (MPC) for selected dates range.

Prototype

async donkiMpc(from: Date, to: Date ): Promise<Result<MagnetopauseCrossing[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const sep: Result<MagnetopauseCrossing[]> = await nasa.donkiMpc(from, to);
donkiRbe

Description

This asynchronous method handles GET /DONKI/RBE REST API, in order to return the Radiation Belt Enhancement (RBE) for selected dates range.

Prototype

async donkiRbe(from: Date, to: Date ): Promise<Result<RadiationBeltEnhancement[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const sep: Result<RadiationBeltEnhancement> = await nasa.donkiRbe(from, to);
donkiHss

Description

This asynchronous method handles GET /DONKI/HSS REST API, in order to return the Hight Speed Stream (HSS) for selected dates range.

Prototype

async donkiRbe(from: Date, to: Date ): Promise<Result<HightSpeedStream[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const sep: Result<HightSpeedStream[]> = await nasa.donkiHss(from, to);
donkiWsa

Description

This asynchronous method handles GET /DONKI/WSAEnlilSimulations REST API, in order to return the WSA+EnlilSimulation for selected dates range.

Prototype

async donkiWsa(from: Date, to: Date ): Promise<Result<WsaEnlilSimulation[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const sep: Result<WsaEnlilSimulation[]> = await nasa.donkiWsa(from, to);
donkiNotifications

Description

This asynchronous method handles GET /DONKI/notifications REST API, in order to return the Notifications for selected dates range.

Prototype

async donkiNotifications(from: Date, to: Date ): Promise<Result<Notification[]>> 

Method parameters

ParameterTypeRequiredDefault
fromDateNo30 days before
toDateNotoday
typeNotificationTypenoall

Sample code

const from = new Date(2023, 2, 21);
const to = new Date(2023, 2, 8);
const sep: Result<Notification[]> = await nasa.donkiNotifications(from, to);

Authors

  • Mario Lazzari - Initial work

Keywords

FAQs

Package last updated on 12 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc