Swiss Ephemeris in WebAssembly (sweph-wasm) vs a hosted API
Several npm packages compile Swiss Ephemeris to WebAssembly. This page covers sweph-wasm, the most downloaded of them in the month to 3 December 2026. It runs the Swiss Ephemeris functions - positions, 25+ house systems, eclipses, fixed stars - in a browser or in Node.js, with no native add-on. Like every Swiss Ephemeris wrapper, it stops at astronomy.
Every sweph-wasm fact below links the page it was read from on .
Honestly
Where sweph-wasm is the better choice
- The chart has to be computed on the user's device. A browser app, an offline PWA or a static site can run Swiss Ephemeris without a server, which no native binding allows.
- One code path for browser and server. The same package runs in modern browsers and Node.js 14+, so a chart preview in the page and a batch job on the backend can share code.
- No native toolchain. There is no C compiler or per-platform binary in your build; a WebAssembly module loads anywhere WebAssembly runs.
- You want Swiss Ephemeris breadth - 25+ house systems, eclipses, fixed stars, heliacal rising and setting - with TypeScript types, rather than the subset an API exposes.
Side by side
What you get vs what you build
| sweph-wasm (self-hosted) | AstroNode API | |
|---|---|---|
| Language / runtime | WebAssembly with a TypeScript wrapper; browsers and Node.js 14+ source | Any language: HTTPS + JSON, OpenAPI 3.1 spec details |
| Install and native build | npm install; async init() before the first call source | Nothing to compile; an API key and an HTTP client details |
| Planet positions | Yes - Sun, Moon, planets, nodes and main asteroids source | Sidereal and tropical, from Swiss Ephemeris data files details |
| House systems | 25+ systems incl. Placidus, Koch, Whole Sign, Sripati source | Whole-sign (Vedic), Placidus (KP), five Western systems details |
| Sidereal / ayanamsa | Sidereal flag documented; choosing the ayanamsa is not 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 | Fetched from a CDN by default, or from a URL you set source | None on your side |
| Time zones and historical offsets | Takes UTC; time-zone handling not documented source | You send the offset in force at birth; no zone-name lookup details |
| Maintenance signal | Latest npm release 2.6.9, published 9 September 2025 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-wasm
- The astrology layer, as with any Swiss Ephemeris wrapper: nakshatras, dashas, vargas, KP sub-lords, panchang limbs, yogas and matching.
- Ayanamsa selection. The README documents the sidereal flag but not a call to choose Lahiri or Krishnamurti; check the typings or source before you depend on it.
- Ephemeris hosting. By default the files come from a CDN; for production you will want to serve them from your own origin and pass that URL.
- Local time to UTC with the historical offset - the README documents UTC input only.
Operations
Running it in production
- Runtime downloads. The default setup fetches ephemeris files from a CDN when your code starts, so first-load time and availability depend on that host. Self-hosting the files gives you control of both.
- Install size. Version 2.6.9 unpacks to about 110 MB on npm. Check it against serverless bundle limits and CI cache budgets, and make sure your web bundler does not ship more than the module and the files you use.
- Pin everything. Its own dependencies are declared as "latest", so a fresh install without a lockfile can pull different versions. Keep the lockfile committed.
- Release cadence. Four versions were published between August and September 2025 and none since. Treat 2.6.9 as a fixed dependency you test yourself.
- 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-wasm's README describes the library as high precision because it is Swiss Ephemeris, but states no figure and does not name the Swiss Ephemeris version compiled in. Precision should follow the upstream engine and the files loaded - see the Swiss Ephemeris page for its 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 above the positions, as endpoints with fixed conventions per tradition.
- No 110 MB package and no ephemeris files fetched at runtime from a third-party CDN.
- Upstream Swiss Ephemeris changes picked up on our side, not waiting on a wrapper release.
- If you need charts with no network at all - offline, in the browser - a WebAssembly build is the better fit, and an API cannot replace it.
sweph-wasm or an API: quick answers
- What do I need to install to use sweph-wasm?
- sweph-wasm: npm install; async init() before the first call. AstroNode API: Nothing to compile; an API key and an HTTP client. Checked 2026-12-05.
- Does sweph-wasm calculate dashas?
- sweph-wasm: Not documented. AstroNode API: Vimshottari, Yogini, Char. Checked 2026-12-05.
- Does sweph-wasm support KP sub-lords?
- sweph-wasm: Not documented. AstroNode API: Cuspal sub-lord chain, significators, horary 1-249. Checked 2026-12-05.
- Does sweph-wasm do kundli matching?
- sweph-wasm: Not documented. AstroNode API: Ashtakoot, Dashakoot, Porutham, batch scoring. Checked 2026-12-05.
- Does sweph-wasm handle time zones and historical offsets?
- sweph-wasm: Takes UTC; time-zone handling not documented. AstroNode API: You send the offset in force at birth; no zone-name lookup. Checked 2026-12-05.
Sources
Quoted from sweph-wasm's own pages
- Language / runtime: “Fast calculations in the browser or Node.js” - https://github.com/ptprashanttripathi/sweph-wasm
- Install and native build: “Initializes the Swiss Ephemeris WebAssembly module.” - https://github.com/ptprashanttripathi/sweph-wasm
- Planet positions: “Calculate positions of planets, moon, sun, and asteroids” - https://github.com/ptprashanttripathi/sweph-wasm
- House systems: “Support for 25+ house systems including Placidus, Koch, Equal House, etc.” - https://github.com/ptprashanttripathi/sweph-wasm
- Sidereal / ayanamsa: “SEFLG_SIDEREAL: Sidereal zodiac” - https://github.com/ptprashanttripathi/sweph-wasm
- Ephemeris data you ship: “Set ephemeris files path (optional, downloads from CDN by default)” - https://github.com/ptprashanttripathi/sweph-wasm
- Time zones and historical offsets: “Convert UTC time to Julian Day.” - https://github.com/ptprashanttripathi/sweph-wasm
- Maintenance signal: “"2.6.9": "2025-09-09T11:51:27.377Z"” - https://registry.npmjs.org/sweph-wasm
- Why this package: “"downloads":41786” - https://api.npmjs.org/downloads/point/last-month/sweph-wasm
- Package size: “"unpackedSize":110593195” - https://registry.npmjs.org/sweph-wasm/2.6.9
- Dependencies: “"wasp-lib":"latest"” - https://registry.npmjs.org/sweph-wasm/2.6.9
- Other features: “Calculate positions and magnitudes of fixed stars” - https://github.com/ptprashanttripathi/sweph-wasm
sweph-wasm 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 · VedicAstro