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

node-apod

v1.6.4

Published

Astronomy Picture of the Day(APOD) scraper for node, support multi-language

Downloads

27

Readme

node-apod

Build Status node version
NPM
"Astronomy Picture of the Day" scraper for node, support multi-language
DEMO PAGE: http://ssarcandy.tw/node-apod/demo.html

Install

npm install --save node-apod

Usage

var APOD = require('node-apod');
var apod = new APOD(API_KEY); // You can get API_KEY at https://api.nasa.gov/index.html#apply-for-an-api-key

apod.get({
    LANG: "en_us", // default en_us
    DATE: '2016-06-24' // default today
}, function(err, data) {
    console.log(data);
});

The response data format as follow:

{
    "lang": "en_us",
    "copyright": "Laurie Hatch",
    "date": "2016-06-23",
    "explanation": "A Full Moon sets as the Solstice Sun rises in this June 20 dawn skyscape. Captured from a nearby peak in central California, planet Earth, the scene looks across the summit of Mount Hamilton and Lick Observatory domes on a calendar date that marks an astronomical change of seasons and hemispherical extremes of daylight hours. Earth's shadow stretches toward the Santa Cruz Mountains on the western horizon. Just above the atmospheric grey shadowband is a more colorful anti-twilight arch, a band of reddened, backscattered sunlight also known as the Belt of Venus. The interplay of solstice dates and lunar months does make this solstice and Full Moon a rare match-up. The next June solstice and Full Moon will fall on the same calendar date on June 21, 2062.",
    "hdurl": "http://apod.nasa.gov/apod/image/1606/LH7407_LickObservatorySolsticeDawnMoonset_1440x960.jpg",
    "media_type": "image",
    "service_version": "v1",
    "title": "Solstice Dawn and Full Moonset",
    "url": "http://apod.nasa.gov/apod/image/1606/LH7407_LickObservatorySolsticeDawnMoonset_1024x683.jpg"
}

Supported language:

  • en_us: English(default)
  • zh_tw: Traditional Chinese
  • cs_cz: Czech
  • fr_fr: French
  • ar_sa: Arabic
  • de_de: German
  • ja_jp: Japanese
  • gl_es: Galician

If LANG is specified(and is valid), response data will get specified LANG's title and explanation.
For example, set LANG as Traditional Chinese:

apod.get({
    LANG: "zh_tw",
    DATE: '2016-06-23'
}, function(err, data) {
    console.log(data);
});

Will Get something like this:

{
    "lang": "zh_tw",
    "copyright": "Laurie Hatch",
    "date": "2016-06-23",
    "explanation": "說明: 在這幅6月20日的黎明天空影像裡,東升的夏至太陽有西沉的滿月為伴。在天文學上標誌南北半球季節更迭和最長和最短白畫的這個日子,攝於地球.加州中部一座山峰的這幅影像,眺望鄰近漢密爾頓山頂和里克天文台的圓頂。影像中,地球的影子綿延向位在西方地平線的聖克魯斯山脈伸展;在灰色的大氣暗影帶之上,可見到名為金星帶的彩反輝弧,一圈由反向散射的陽光所構成的泛紅光帶。交替出現的至日與農曆月份,恰好在這一天帶來了罕見的夏至與滿月的交會。下一次夏至與滿月重逢,則要等到2062年的6月21日。(Mount \r\nHamilton 漢密爾頓山、漢莫頓山)",
    "hdurl": "http://apod.nasa.gov/apod/image/1606/LH7407_LickObservatorySolsticeDawnMoonset_1440x960.jpg",
    "media_type": "image",
    "service_version": "v1",
    "title": "夏至黎明與滿月西沉",
    "url": "http://apod.nasa.gov/apod/image/1606/LH7407_LickObservatorySolsticeDawnMoonset_1024x683.jpg"
}

Error Handle

[LANG] version not found.

The main site(NASA) is the first to update and the most likely to be up-to-date.
For those other languages mirror sites, maybe not alway up-to-date.

If happended, will get error as follow:

apod.get({
    LANG: "fr_fr",
    DATE: '2016-06-24'
}, function(err, data) {
    if (err) {
        console.error(err);
        // 2016-06-24 don't have(or not yet) fr_fr version.
    }
});

Response code not 200

If you get this error, means that the APOD servers cannot be reached.