sweph for Node.js vs a hosted astrology API
sweph wraps the Swiss Ephemeris C library as a Node.js native add-on: every function of the C API, typed for TypeScript, with its version number tied to the upstream release. For a Node backend it is the direct route to in-process positions. Like the C library, it stops at astronomy - houses and ayanamsas yes, dashas and panchang no.
Every sweph fact below links the page it was read from on .
Honestly
Where sweph is the better choice
- Your backend is Node.js and you want positions in-process. A native call avoids a network hop on every chart, which matters for search loops (next ingress, next station) and batch jobs.
- You want the full C API, not a subset: fixed stars, eclipses, heliocentric and topocentric frames, every house method and sidereal mode. The README claims 100% coverage, and the official Swiss Ephemeris programmer's manual applies directly.
- You want to know exactly which upstream you run. Versions are locked to Swiss Ephemeris releases - 2.10.4 is Swiss Ephemeris 2.10.04 - and the latest release is from November 2026.
- TypeScript in the editor. Declarations and inline documentation ship with the package, so each function's arguments show up as you type.
Side by side
What you get vs what you build
| sweph (self-hosted) | AstroNode API | |
|---|---|---|
| Language / runtime | Node.js only - a native C/C++ add-on, not for browsers source | Any language: HTTPS + JSON, OpenAPI 3.1 spec details |
| Install and native build | Prebuilt binaries; otherwise a native build with a C toolchain source | Nothing to compile; an API key and an HTTP client details |
| Planet positions | Yes - the whole Swiss Ephemeris API source | Sidereal and tropical, from Swiss Ephemeris data files details |
| House systems | Yes - the C library's house functions source | Whole-sign (Vedic), Placidus (KP), five Western systems details |
| Sidereal / ayanamsa | Yes - set_sid_mode(), but the setting is process-wide source | Fixed per tradition: Lahiri, KP-Newcomb, tropical details |
| Dashas | Not documented | Vimshottari, Yogini, Char details |
| Divisional charts (vargas) | Not documented | 16 vargas in one call, plus D150 details |
| KP sub-lords | Not documented | Cuspal sub-lord chain, significators, horary 1-249 details |
| Panchang | Not documented | Tithi, nakshatra, yoga, karana, sunrise, muhurta windows details |
| Yogas | Not documented | 55 classical yogas with reasons details |
| Kundli matching | Not documented | Ashtakoot, Dashakoot, Porutham, batch scoring details |
| Ephemeris data you ship | None included; download .se1 files and call set_ephe_path() source | None on your side |
| Time zones and historical offsets | Not handled (same as the C library); pass UT source | You send the offset in force at birth; no zone-name lookup details |
| Maintenance signal | Active: 2.10.4 on npm, published 27 November 2026 source | Hosted; changes published in the changelog details |
| Stated accuracy | Not documented | Measured in CI vs NASA JPL Horizons: Moon 3.1″, planets ≤ 0.5″ (1900-2050) details |
“Not documented” means the project's own README and docs do not describe it - not that it is impossible to build on top.
On top
What you would still write with sweph
- The Vedic layer: nakshatras, dasha periods, sixteen vargas, the KP sub-lord table, tithi/yoga/karana with end times, yogas and matching. sweph gives you the longitudes those rules start from.
- Per-request conventions. set_sid_mode() and set_ephe_path() are process-wide, so a server that mixes Lahiri and Krishnamurti requests must serialise calls or split the work across child processes.
- Ephemeris provisioning: download the .se1 files you need from the Swiss Ephemeris repository and ship them with each deployment.
- Local time to UT with the historical offset for the birthplace.
- A separate path for browsers and edge runtimes, where a native add-on cannot load.
Operations
Running it in production
- Native binaries. Prebuilds cover the supported platforms; anywhere else, npm install falls back to a source build that needs python, make and gcc on Linux, Xcode on macOS or the Visual C++ build tools on Windows. Check your CI image and deploy target before relying on the prebuild.
- Data files. Each main file covers 600 years (sepl_18.se1 is 1800-2400); planets, Moon and asteroids are separate files. As with the C library, a wrong path means the engine falls back to its lower-precision built-in model rather than failing.
- Concurrency. worker_threads share the C library's global settings; true isolation needs child_process.
- Upstream changes arrive as new sweph versions that match Swiss Ephemeris releases - a dependency bump and a native rebuild on your side.
- Whatever the library, the birth input is a local clock time, and turning it into UT needs the offset that was in force on that date - our UTC offset finder and the time-zone guide cover the traps.
Accuracy
What the numbers say
sweph's README states no accuracy figure of its own. It runs Swiss Ephemeris 2.10.04, so precision is whatever that engine and the data files you install deliver - see the Swiss Ephemeris page for the upstream figures. AstroNode's CI compares positions with NASA JPL Horizons and measured the Moon within 3.1″ and every planet within 0.5″ from 1900 to 2050.
And
Where an API saves work
- The Vedic rules on top of the positions - three dasha systems, sixteen vargas, KP sub-lords, panchang, 55 yogas and matching - as endpoints.
- No native build matrix and no .se1 directory in every container.
- Per-request conventions without process-wide state: each call carries its own tradition, so Lahiri and KP requests never interfere.
- Works from browsers, React Native and edge runtimes, where a Node add-on cannot run.
sweph or an API: quick answers
- What do I need to install to use sweph?
- sweph: Prebuilt binaries; otherwise a native build with a C toolchain. AstroNode API: Nothing to compile; an API key and an HTTP client. Checked 2026-12-05.
- Does sweph calculate dashas?
- sweph: Not documented. AstroNode API: Vimshottari, Yogini, Char. Checked 2026-12-05.
- Does sweph support KP sub-lords?
- sweph: Not documented. AstroNode API: Cuspal sub-lord chain, significators, horary 1-249. Checked 2026-12-05.
- Does sweph do kundli matching?
- sweph: Not documented. AstroNode API: Ashtakoot, Dashakoot, Porutham, batch scoring. Checked 2026-12-05.
- Does sweph handle time zones and historical offsets?
- sweph: Not handled (same as the C library); pass UT. AstroNode API: You send the offset in force at birth; no zone-name lookup. Checked 2026-12-05.
Sources
Quoted from sweph's own pages
- Language / runtime: “This library is a C/C++ add-on designed for Node.JS only” - https://github.com/timotejroiko/sweph
- Install and native build: “Prebuilt binaries are included for supported platforms.” - https://github.com/timotejroiko/sweph
- Planet positions: “100% API coverage” - https://github.com/timotejroiko/sweph
- House systems: “Everything you need to create Astrology and Astronomy applications with JavaScript and Node.JS” - https://github.com/timotejroiko/sweph
- Sidereal / ayanamsa: “Functions such as set_ephe_path() or set_sid_mode() will affect the entire process” - https://github.com/timotejroiko/sweph
- Ephemeris data you ship: “This library does not include any ephemeris files by default” - https://github.com/timotejroiko/sweph
- Time zones and historical offsets: “conversion to local time zone must be made by the user.” - https://www.astro.com/swisseph/swephprg.htm
- Maintenance signal: “"2.10.4": "2026-11-27T22:49:06.266Z"” - https://registry.npmjs.org/sweph
- Upstream version: “Current Version: 2.10.4 (Swiss Ephemeris 2.10.04)” - https://github.com/timotejroiko/sweph
- Threads: “true thread-safe multithreading can only be achieved using child_process.” - https://github.com/timotejroiko/sweph
- TypeScript: “Built-in Typescript declarations and ESM exports” - https://github.com/timotejroiko/sweph
sweph is named only to identify the project. Values were read from public pages on 5 December 2026; projects change, so check their pages before you decide, and tell us if anything here is out of date.
Other options: Swiss Ephemeris · pyswisseph · Kerykeion · Flatlib · PyJHora · Astronomy Engine · Skyfield · Immanuel · sweph-wasm · VedicAstro