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 🙏

© 2026 – Pkg Stats / Ryan Hefner

astronomyapi-client

v1.0.1

Published

An interface to astronomyapi.com

Readme

astronomyapi-client

This package exposes the astronomyapi.com API as handy classes and helper methods for easily querying the different endpoints in this API. See https://docs.astronomyapi.com for details about the API and what it returns.

Defaults and Configuration

You will need your own Application ID and Application key from astronomyapi.com. See the Getting Started section for instructions on how to get this (it is free). Once you have it, you'll need to either set the ASTRONOMYAPI_APPLICATION_ID and ASTRONOMYAPI_APPLICATION_SECRET environment variables, or pass them into the constructors for Request objects.

This package uses some defaults for parameters that are based on environment variables. You can set those defaults by setting the ASTRONOMYAPI_DEFAULT* environment variables below - either in a .env file or in your shell.

Example:

ASTRONOMYAPI_DEFAULT_LATITUDE=37.25626720108698
ASTRONOMYAPI_DEFAULT_LONGITUDE=-121.94236276119172
ASTRONOMYAPI_DEFAULT_ELEVATION=3
ASTRONOMYAPI_APPLICATION_ID=your_id_from_astronomyapi.com
ASTRONOMYAPI_APPLICATION_SECRET=your_secret_from_astronomyapi.com

Parameter Helpers

The API takes a few common objects as input parameters, and these are encapsualted as classes. Generally, each class takes a hash of fields and values. Each field listed in the docs is a valid field to include in the constructor hash. Any hierarchy in the inputs described in the docs are flattened in these helper classes for convenience. These classes are:

{ ObserverParameters, ViewParameters, StyleParameters }

Request Helpers

A class exists for each endpoint, and they all accept an object representing the parameters for that endpoint. In some cases, the endpoint will be a combination of the above parameter objects. See the API docs for more details. Each class has an asynchronous fetch method to initiate the request. When the request completed the request object will have response and data fields populated for you to consume the results. Here are some examples of the request helpers in action:

const { format } = require('date-fns');
const { PositionRequest, ObserverParameters, EventRequest, BodiesEnumRequest, StarChartRequest, ViewParameters, MoonPhaseRequest, StyleParameters } = require('astronomyapi-client');

async function main() {
  const today = new Date();
  const nextMonth = new Date(today.setMonth(today.getMonth() + 1));
  
  // Make a position request
  pr = new PositionRequest();
  // override the `to_date` input parameter to be a month from now
  op = new ObserverParameters({to_date: format(nextMonth, 'yyyy-MM-dd')});
  await pr.fetch(op);

  er = new EventRequest();
  // EventRequest's `fetch` accepts an extra argument - the body id
  await er.fetch(op, "sun");

  br = new BodiesEnumRequest();
  await br.fetch(op);

  sr = new StarChartRequest();
  sr_params = {
    observer: op,
    view: new ViewParameters(),
  }
  await sr.fetch(sr_params);

  mr = new MoonPhaseRequest();
  mr_params = {
    observer: op,
    view: new ViewParameters({type: 'landscape-simple'}),
    style: new StyleParameters(),
  }
  await mr.fetch(mr_params);
}

main();