@astrology/api-service
Transport-neutral service layer behind the HTTP API. It holds every operation the Express controllers expose, so code in the same process can call them directly with no HTTP involved.
import { createProviderApi } from '@astrology/api-service';
const api = await createProviderApi({ nasaUserAgent: 'my-app/1.0 (me@example.com)' });
const birth = { instant: '2000-01-01T12:00:00Z', houseObserver: { latitude: 19.076, longitude: 72.8777 } };
const dasha = await api.vedic!.dasha(birth);
const natal = await api.western!.natal(birth);
createAstrologyApi(runtime)wraps an already assembled@astrology/runtime.createProviderApi(options)builds one with real Swiss and Horizons providers, default probe limits and the Espenak–Meeus ΔT resolver (ΔT is the gap between atomic-based Terrestrial Time and Earth-rotation Universal Time).api.vedic:chart, the shortcuts inVEDIC_SHORTCUTS(see varga, dasha, shadbala, ashtakavarga, yoga, drishti; panchang, muhurta, matching) (varga,dasha,shadbala,ashtakavarga,yogas,drishti,judgments), the operations inVEDIC_OPERATIONS(panchang,muhurta,transits,matching) andcapabilities.api.western:chart, one shortcut per entry inWESTERN_TECHNIQUES,compose(the tropical snapshot: longitudes, houses and angles, for drawing a wheel) andcapabilities.- A disabled tradition is
null;api.health()reports which traditions are enabled.
Inputs are plain objects, such as parsed JSON. Shortcuts take
{ instant, houseObserver?, positionObserver?, profile?, allowPartial?, request? } and copy only those
fields. Input that is not an object, or that has no instant, throws
ApiError('INVALID_REQUEST') before any engine call. Engine errors pass through unchanged with
their own code, so in-process callers and the HTTP app branch on the same codes.
Run pnpm --filter @astrology/api-service build, check and test. The tests include an
in-process run with real providers.