npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

r4nasa-api

v1.0.5

Published

Package to return space data from nasa APIs

Downloads

19

Readme

r4nasa-api -Get space data easy

alt text

[Github [npm downloads [GitHub

npm package

NPM Version node js-standard-style [version [use

In development.

Installation

just type this to install the module

$ npm install r4nasa-api

this module has dependencies so it works only if fs and https are installed also this module has a function that retuns the data you requested in a json file called requested_data.json

$ npm install https
$ npm install file system

Example

at top add the two constants for r4nasa and fs

const r4nasa = require('r4nasa-api')
const fs = require('fs');

then add the line

const R4nasa = new r4nasa({token:'YOUR_TOKEN'});

replace YOUR_TOKEN with your registration token where you can found it Here

Random Mars images by sol

to get thousands random Mars images by random rovers you have to request data with a function that returns 1 image and some data type

R4nasa.RequestMars_sol(rover, sol)

in the two parameters you have to add the rover name(Curiosity is the rover with more data) and a random sol

this will create and write data in a json filed called requested_data.json

{
"img":"http://mars.jpl.nasa.gov/msl-raw-images/proj/msl/redops/ods/surface/sol/01344/opgs/edr/fcam/FRB_516810721EDR_F0541238FHAZ00304M_.JPG",
"sol":1344,
"rover":"Curiosity",
"date":"2016-05-17"
}

and then in your script you have to parse the data with fs module that you have installed

//don't change requested_data.json path!
let rawdata = fs.readFileSync('./requested_data.json');  
var json = JSON.parse(rawdata)
//here are you going to get the img value in the json file 
console.log(json.img)

the final script will looks like

const r4nasa = require('r4nasa-api')
const fs = require('fs');
const R4nasa = new r4nasa({token:'YOUR_TOKEN'});

//this is the parse function that will be parse the data in the json file
function parse()
{
let rawdata = fs.readFileSync('./requested_data.json');  
var json = JSON.parse(rawdata)
//here are you going to get the img value in the json file
console.log(json.img)
}

//this is a random number for a random sol
var randomSOL = Math.floor(Math.random() * 2394);

// writing and creating the file with data
R4nasa.RequestMars_sol("Curiosity", randomSOL)
// generating data requires time, and if the parse function is called before RequestMars_sol finish this will return an error 
setTimeout(parse, 3800);

the module is still in development so it doesn't have all the functions