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-sunsetwx

v0.0.1

Published

A wrapper for SunsetWx's Sunburst API, which provides sunset and sunrise quality forecasts.

Downloads

3

Readme

node-sunsetwx :sunrise:

node-sunsetwx is a Node.js wrapper for SunsetWx's Sunburst API, which provides sunset and sunrise quality forecasts.

Currently, the API is in beta. To get started you need to email [email protected] to get a registration key.

You'll want to reference the Sunburst API docs for more detailed info on parameters and responses.

Installation

$ npm install node-sunsetwx

Registering

Before you interact with the API, you need to register your email address and password using the registration key you received. This is a one-time task. An email confirmation will be sent, which you need to acknowledge before you'll be able to log in.

Since you'll only be doing this once, you might as well do it in the interactive Node.js REPL:

$ node

Load the library:

var SunsetWx = require('node-sunsetwx');

Create the API object, including your email, a password (longer than six characters, at least one uppercase, one lowercase, and one number), and your registration key:

var sunsetwx = new SunsetWx({
  email: '[email protected]',
  password: '12345Ab',
  key: 'fOd2dUpB3L5oq42CKOq7NPsX'
});

Call the .register method, with a callback to print the response:

sunsetwx.register(function(err, response, body){
  console.log(body);
});

You should see this:

{
  "message": "Verification email sent"
}

Click the link in the verification email before continuing.

Usage

Note: all callbacks are passed directly to the requests library, which handles the actual https request. Thus, callbacks will receive the following as described by requests:

  1. An error, if applicable
  2. An http.IncomingMessage object
  3. The response body, as a JSON object

For much more detail on API parameters and responses, please read the Sunburst API Docs.

Constructor

Creates a new API object with (minimally) your email and password. Automatically handles login, authentication, and auth token refresh.

var sunsetwx = new SunsetWx({
  email: '[email protected]',
  password: '12345Ab'
});

Parameters

  • email: (required) the email you signed up with
  • password: (required) the password you chose when registering
  • key: (optional) your registration key, only required for registration
  • base_url: (optional) an alternate base URL for the API. (default: https://sunburst.sunsetwx.com/v1/)

.register(callback)

Registers the email and password using the key provided to the constructor.

sunsetwx.register(callback)

.login(callback)

Logs in using the email and password provided to the constructor, storing the auth token for use during subsequent API calls. This is handled automatically, so you should actually never have to call .login() manually.

sunsetwx.login(callback)

.logout(callback)

Logs out the current auth token and destroys it.

sunsetwx.logout(callback)

.passwordReset(callback)

Triggers a password reset request. You will receive an email with a link to complete the process.

sunsetwx.passwordReset(callback)

.deleteAccount(callback)

Deletes the current account. Note: this cannot be undone.

sunsetwx.deleteAccount(callback)

.coordinates(params, callback)

Returns longitude and latitude coordinates for the given location string.

sunsetwx.coordinates({
  location: 'Rochester, NY'
}, callback)

Parameters

  • location: (required) a string that contains a location name

.location(params, callback)

Returns a location name for the coordinates in coords

sunsetwx.location({
  coords: '-77.331536,43.271152'
}, callback)

Parameters

  • coords: (required) a string that contains valid longitude and latitude, separated by only a comma.

.quality(params, callback)

sunsetwx.quality({
  coords: '-77.331536,43.271152',
  type: 'sunset',
  location: 'northamerica',
  radius: '24.02',
  limit: '42',
  timestamp: '2016-07-07T16:26:08Z'
}, callback)

Parameters

  • coords: (required) a string that contains valid longitude and latitude, separated by only a comma.
  • type: (required) a string to indicate 'sunrise' or 'sunset'
  • location: (optional) a string containing a valid model location of 'global' or 'northamerica'
  • radius: (optional) a number that limits the returned points to the indicated radius in kilometers.
  • limit: (optional) an integer that limits the number of returned points
  • timestamp: (optional) a valid RFC3339 timestamp within the next three days, for prediction of future sunrises and sunsets.

Contributing

Sure.

License

This software is licensed under the MIT License. See the LICENSE file for details.