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

apod

v0.3.0

Published

Wrapper around NASA's APOD API

Downloads

4

Readme

apod.js

A small JS wrapper around NASA's APOD API.

To use this, you'll need an api.data.gov API key - you can request one here: https://data.nasa.gov/developer/external/planetary/#apply-for-an-api-key

Installation

$ npm install apod

Usage

var apod = require("apod");

apod.apiKey = "YOUR_API_KEY";

function callback(err, data) {
  // do cool stuff with APOD data here
}

// get today's APOD
apod(callback);

// APOD for December 31, 1999 (JS has 0-indexed months)
apod(new Date(1999, 11, 31), callback);

// the same
apod(1999, 11, 31, callback);

// once more, with feeling
apod("December 31, 1999" callback);

// get a random APOD
apod.random(callback);

Assuming success, all methods trigger the callback with an object like the following, direct from NASA's API:

{
  "concept_tags": true,
  "title": "The Millennium that Defined Earth",
  "url": "http://apod.nasa.gov/apod/image/9912/earthrise_apollo8.jpg",
  "explanation": "When the second millennium began, people generally knew that [...]",
  "concepts": {"0": "Galaxy", "1": "Milky Way", "2": "Earth", "3": "Solar System", "4": "Universe", "5": "Sun", "6": "Planet", "7": "Gravitation"},
  "date": "1999-12-31"
}

HTTPS Proxy

Sending via an HTTP/HTTPS proxy is supported. Just set the environment variable https_proxy and it will be used when making requests to the API. Alternatively, set the apod.proxy string.

Here's examples of both usage patterns:

$ https_proxy="https://my.secure.proxy" node script.js
// script.js
apod.proxy = "https://my.secure.proxy"

Version History

Version | Notes ------- | ----- 0.2.0 | Update endpoint URL, remove concept_tags 0.2.0 | Add support for HTTPS proxy, refactors. 0.1.0 | Interface change, use new NASA APOD API 0.0.1 | Initial release

License

MIT. For more details, see the LICENSE file.