celestial-bodies

0.0.4 • Public • Published

Celestial Bodies


🚀 Lightweight wrapper for NASA's API library.

Introduction

Celestial Bodies is a lightweight wrapper for NASA's API library.

Table of Contents

🌑 System Requirements 🌒 Installation 🌙 Usage 🌔 Contributing 🌕 Credits

System Requirements

At its core, Celestial Bodies relies on Node.js and NPM for its core functionality.

  • Node ^14
  • NPM ^6

Installation

npm install celestial-bodies

🛰️ Usage

Require the package to access the preconfigured API functions.

const celestial = require('celestial-bodies');

Each API function takes a payload object which includes the necessary data to process the request.

The key value is required for all calls. You can leave it as DEMO_KEY and the functions will still work as intended, but the API call limitations will be stricter. Otherwise, request a free API code from NASA's website and use that as the key value (recommended).

APOD

The apod() function is used to leverage the Astronomy Picture of the Day API.

The Date parameter specifies the date for the returned image. Date will default to today if empty, and is expecting the YYYY-MM-DD format.

You can also use start_date and end_date parameters to get a range of dates and their associated images. End date is today by default.

The count parameter is available for querying a number of random images. If you use count you cannot use any of the other three date parameters.

If the picture of the day is a video, you can use the thumbs parameter to specify whether you want it to return a video thumbnail or not. Defaults to false.

const payload = {
  key: 'DEMO_KEY',
  date: '',
  hd: ''
};

celestial.apod(payload, pictureOfTheDay => {
  return pictureOfTheDay;
});

Asteroids

The asteroids() function provides access to NASA's Near Earth Object Web Service. This call has three separate modes - feed, lookup, and browse.

Feed

For this mode, provide your key in the request along with the start_date and end_date for the range of dates you would like results for. This range can be no more than seven days.

const payload = {
  end_date: '2021-01-01',
  key: 'DEMO_KEY',
  start_date: '2021-01-02',
  type: 'feed'
};

celestial.apod(payload, asteroid => {
  return asteroid;
});
Lookup

In addition to your key, you need to provide the request with the asteroid_id, which is the id of the asteroid you're looking up.

const payload = {
  asteroid_id: 3471590,
  key: 'DEMO_KEY',
  type: 'lookup'
};

celestial.apod(payload, asteroid => {
  return asteroid;
});
Browse

This mode doesn't require any parameters aside from the api key.

These mode values are passed in through type payload parameter.

const payload = {
  key: 'DEMO_KEY',
  type: 'browse'
};

celestial.apod(payload, asteroid => {
  return asteroid;
});

Contributing

Contributions are welcome - feel free to submit a pull request and it will be reviewed promptly.

Credits

Core Packages

Axios

Misc. Assets

Looka

Bonus

Please the project if you enjoy it - much appreciated!

Package Sidebar

Install

npm i celestial-bodies

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

99.1 kB

Total Files

27

Last publish

Collaborators

  • jeffreyallanbrown