← Self-hosting vs an API

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 compared with the AstroNode API, checked 5 December 2026
 sweph-wasm (self-hosted)AstroNode API
Language / runtimeWebAssembly with a TypeScript wrapper; browsers and Node.js 14+ sourceAny language: HTTPS + JSON, OpenAPI 3.1 spec details
Install and native buildnpm install; async init() before the first call sourceNothing to compile; an API key and an HTTP client details
Planet positionsYes - Sun, Moon, planets, nodes and main asteroids sourceSidereal and tropical, from Swiss Ephemeris data files details
House systems25+ systems incl. Placidus, Koch, Whole Sign, Sripati sourceWhole-sign (Vedic), Placidus (KP), five Western systems details
Sidereal / ayanamsaSidereal flag documented; choosing the ayanamsa is not sourceFixed per tradition: Lahiri, KP-Newcomb, tropical details
DashasNot documentedVimshottari, Yogini, Char details
Divisional charts (vargas)Not documented16 vargas in one call, plus D150 details
KP sub-lordsNot documentedCuspal sub-lord chain, significators, horary 1-249 details
PanchangNot documentedTithi, nakshatra, yoga, karana, sunrise, muhurta windows details
YogasNot documented55 classical yogas with reasons details
Kundli matchingNot documentedAshtakoot, Dashakoot, Porutham, batch scoring details
Ephemeris data you shipFetched from a CDN by default, or from a URL you set sourceNone on your side
Time zones and historical offsetsTakes UTC; time-zone handling not documented sourceYou send the offset in force at birth; no zone-name lookup details
Maintenance signalLatest npm release 2.6.9, published 9 September 2025 sourceHosted; changes published in the changelog details
Stated accuracyNot documentedMeasured 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

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