# 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.

Source: https://astronode.dev/compare/self-hosting/sweph-wasm · Facts checked: 2026-12-05

## When self-hosting 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

|  | sweph-wasm | AstroNode API |
| --- | --- | --- |
| Language / runtime | WebAssembly with a TypeScript wrapper; browsers and Node.js 14+ ([source](https://github.com/ptprashanttripathi/sweph-wasm)) | Any language: HTTPS + JSON, OpenAPI 3.1 spec ([details](https://astronode.dev/guides/openapi-typed-client)) |
| Install and native build | npm install; async init() before the first call ([source](https://github.com/ptprashanttripathi/sweph-wasm)) | Nothing to compile; an API key and an HTTP client ([details](https://astronode.dev/quickstart/curl)) |
| Planet positions | Yes - Sun, Moon, planets, nodes and main asteroids ([source](https://github.com/ptprashanttripathi/sweph-wasm)) | Sidereal and tropical, from Swiss Ephemeris data files ([details](https://astronode.dev/capabilities/vedic)) |
| House systems | 25+ systems incl. Placidus, Koch, Whole Sign, Sripati ([source](https://github.com/ptprashanttripathi/sweph-wasm)) | Whole-sign (Vedic), Placidus (KP), five Western systems ([details](https://astronode.dev/guides/house-systems)) |
| Sidereal / ayanamsa | Sidereal flag documented; choosing the ayanamsa is not ([source](https://github.com/ptprashanttripathi/sweph-wasm)) | Fixed per tradition: Lahiri, KP-Newcomb, tropical ([details](https://astronode.dev/guides/ayanamsa)) |
| Dashas | Not documented | Vimshottari, Yogini, Char ([details](https://astronode.dev/guides/vimshottari-dasha-calculation)) |
| Divisional charts (vargas) | Not documented | 16 vargas in one call, plus D150 ([details](https://astronode.dev/guides/divisional-chart-calculation)) |
| KP sub-lords | Not documented | Cuspal sub-lord chain, significators, horary 1-249 ([details](https://astronode.dev/capabilities/kp)) |
| Panchang | Not documented | Tithi, nakshatra, yoga, karana, sunrise, muhurta windows ([details](https://astronode.dev/guides/panchang-sunrise-conventions)) |
| Yogas | Not documented | 55 classical yogas with reasons ([details](https://astronode.dev/capabilities/vedic)) |
| Kundli matching | Not documented | Ashtakoot, Dashakoot, Porutham, batch scoring ([details](https://astronode.dev/capabilities/compatibility)) |
| Ephemeris data you ship | Fetched from a CDN by default, or from a URL you set ([source](https://github.com/ptprashanttripathi/sweph-wasm)) | None on your side |
| Time zones and historical offsets | Takes UTC; time-zone handling not documented ([source](https://github.com/ptprashanttripathi/sweph-wasm)) | You send the offset in force at birth; no zone-name lookup ([details](https://astronode.dev/guides/birth-time-and-time-zones)) |
| Maintenance signal | Latest npm release 2.6.9, published 9 September 2025 ([source](https://registry.npmjs.org/sweph-wasm)) | Hosted; changes published in the changelog ([details](https://astronode.dev/changelog)) |
| Stated accuracy | Not documented | Measured in CI vs NASA JPL Horizons: Moon 3.1″, planets ≤ 0.5″ (1900-2050) ([details](https://astronode.dev/)) |

| More from their docs |  |
| --- | --- |
| Why this package | Most downloaded Swiss Ephemeris WASM package on npm, Nov 2026 ([source](https://api.npmjs.org/downloads/point/last-month/sweph-wasm)) |
| Package size | About 110 MB unpacked (2.6.9) ([source](https://registry.npmjs.org/sweph-wasm/2.6.9)) |
| Dependencies | Declared as "latest", not pinned ([source](https://registry.npmjs.org/sweph-wasm/2.6.9)) |
| Other features | Eclipses, fixed stars, heliacal events, refraction ([source](https://github.com/ptprashanttripathi/sweph-wasm)) |

## What you still build yourself

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

## 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](https://astronode.dev/tools/utc-offset-finder) and the [time-zone guide](https://astronode.dev/guides/birth-time-and-time-zones) cover the traps.

## Accuracy

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.

## 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.

## Questions

**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.
