← Self-hosting vs an API

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 compared with the AstroNode API, checked 5 December 2026
 sweph (self-hosted)AstroNode API
Language / runtimeNode.js only - a native C/C++ add-on, not for browsers sourceAny language: HTTPS + JSON, OpenAPI 3.1 spec details
Install and native buildPrebuilt binaries; otherwise a native build with a C toolchain sourceNothing to compile; an API key and an HTTP client details
Planet positionsYes - the whole Swiss Ephemeris API sourceSidereal and tropical, from Swiss Ephemeris data files details
House systemsYes - the C library's house functions sourceWhole-sign (Vedic), Placidus (KP), five Western systems details
Sidereal / ayanamsaYes - set_sid_mode(), but the setting is process-wide 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 shipNone included; download .se1 files and call set_ephe_path() sourceNone on your side
Time zones and historical offsetsNot handled (same as the C library); pass UT sourceYou send the offset in force at birth; no zone-name lookup details
Maintenance signalActive: 2.10.4 on npm, published 27 November 2026 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

  • 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

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