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

swisseph-node

v1.0.1

Published

Modern N-API binding for Swiss Ephemeris — self-contained (vendored C sources), ships prebuilt binaries, bundle-friendly (base64-embedded fallback for serverless/bundler-only runtimes)

Readme

swisseph-node

Modern Node.js binding for the Swiss Ephemeris — N-API (stable ABI), compiles the upstream C sources unmodified.

Why another binding?

The classic swisseph npm package is NAN-based (must be rebuilt for every Node major), forks and patches the C code (hard to track upstream), and has been unmaintained for years. This package:

  • Zero modifications to upstream C code — binding.gyp compiles the pristine sources directly, so updating to a new Swiss Ephemeris release is just dropping in the new .c/.h files and rebuilding.
  • N-API / node-addon-api — one build works across Node major versions (≥16).
  • Clean layered API — a faithful low-level mapping (raw) plus a high-level chart/synastry/sky API returning structured data ready for chart rendering.
  • No bundled data — points at the Swiss Ephemeris files you already have (env var SWISSEPH_EPHE_PATH), falling back to the built-in Moshier ephemeris when none are found.

Install / build

The Swiss Ephemeris C sources are vendored inside the package (vendor/, unmodified), so npm install swisseph-node just works. Prebuilt binaries ship for linux x64/arm64 and darwin x64/arm64 (N-API: one build works across Node majors ≥16); other platforms compile from vendor/ via npm rebuild swisseph-node.

Updating to a new Swiss Ephemeris release = dropping the new .c/.h files into vendor/ and bumping the version (CI regenerates prebuilds).

Bundle / serverless environments (esbuild, EdgeOne Cloud Functions, …)

Bundlers that inline everything into a single JS file leave no .node binary on disk. The loader (lib/raw.js) handles this: it falls back to base64-embedded binaries (lib/b64/<platform>.js, generated by scripts/gen-b64.js from the prebuilds), decodes one to os.tmpdir() on first use and loads it. Nothing to configure.

Ephemeris data files (semo_*.se1, sepl_*.se1, seas_*.se1) are resolved at runtime from:

  1. setEphePath(path) — explicit
  2. SWISSEPH_EPHE_PATH env var
  3. ../swisseph-master/ephe relative to the package

Without data files it silently falls back to the Moshier analytical ephemeris (planets only, slightly lower precision — Chiron/asteroids unavailable).

High-level API

const swe = require('swisseph-node');

const chart = swe.computeChart({
  year: 2000, month: 1, day: 1, hour: 20, tz: 8,   // local time + UTC offset
  lat: 39.9042, lon: 116.4074,                      // Beijing
  houseSystem: 'P',                                 // Placidus
});
// chart.planets -> [{key:'sun', lon, sign:'capricorn', house, retrograde, speed, degreeInSign, ...}]
// chart.houses  -> {cusps[12], ascendant, midheaven, vertex, cuspsFormatted}
// chart.aspects -> [{a:'sun', b:'moon', aspect:{key:'square', orbDelta:1.2, ...}}]
// chart.balances-> {elements:{fire:3,...}, modes:{...}}

const syn = swe.computeSynastry(birthA, birthB);
// syn.crossAspects, syn.aHousesOfB, syn.bHousesOfA

const sky = swe.computeSky({ year: 2026, month: 10, day: 24, hour: 21, tz: 8, lat: 39.9, lon: 116.4 });
// sky.bodies -> [{key:'moon', azimuth, altitude, illumination}]
// sky.stars  -> bright-star catalog with horizontal coordinates

Low-level API (raw)

One-to-one with the C API (swephexp.h): version, setEphePath, julDay, revJul, utcToJd, utcTimeZone, deltat, calcUt, houses, getPlanetName, ayanamsaUt, azAlt, phenoUt, solEclipseWhenLoc, lunOccultWhenLoc, setTopo, setSidMode, close.

Test

npm test

Verified against reference values generated by the upstream swetest binary (sub-milliarcsecond agreement).

License

AGPL-3.0 (as Swiss Ephemeris). Commercial licensing for the underlying ephemeris may be obtained from Astrodienst.