Skip to content
AstroWay/api v2.219.1 · docs
all systems operational

Chinese metaphysics API

53 endpoints across four families: BaZi (18), the Chinese calendar and zodiac (15), Zi Wei Dou Shu (14) and I Ching (6). The calendar is derived from the ephemeris rather than from date tables, so it works for years 2 through 2899 and does not depend on whether somebody refreshed a reference.

FamilyEndpointsState
BaZi: pillars and analysis18The full classical apparatus
Calendar, zodiac, feng shui, Tong Shu15Derived from the ephemeris
Zi Wei Dou Shu14Star placement computed, eleven glossaries stay glossaries
I Ching6Hexagrams, coin toss, changing lines

The honest answer: if all you need is the four pillars, take lunar-typescript. It is MIT, it runs in your own process, offline, with no rate limit, and you should not pay for that.

The difference starts where the library stops.

FeatureMIT librariesAstroWay API
Four pillars, 藏干, na yin, 十神yesyes
神煞 with both readings where the schools partnoyes
Branch interactions 刑冲合害noyes
Day-master strength in the 扶抑 framenoyes
True solar time as a first-class computationnoyes
Flying stars by sitting and facing, the Kua numbernoyes
Tong Shu date selection filtered by activitynoyes
Twenty-one languagesnoyes
One convention across PHP, JavaScript and Python at oncenoyes

That last row is what people actually pay for. A team whose site is PHP, whose app is JavaScript and whose crons are Python otherwise keeps three implementations of the year boundary, and sooner or later gets three different answers for one birth date.

Four axes where calculators part company, and none of them is a bug. Most implementations choose silently; we write the choice into the response and keep a conventions page with a run against an external CC0 dataset.

AxisOur answer
Year boundary立春 Lichun, the exact instant from the ephemeris
Day rollover23:00, so the early 子時 belongs to the next day
True solar timeoff by default, switched on by a flag
Daylight savingsettled by the timezoneOffset the client sends
Terminal window
curl -X POST https://api.astroway.info/v1/bazi/chart \
-H "X-Api-Key: $ASTROWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"date":"1990-05-15","time":"14:30:00","timezoneOffset":3}'

Live demo and the code on GitHub, MIT.

Two calls, POST /v1/bazi/chart at 20 credits and POST /v1/bazi/luck-pillars at 10, return the four pillars with their hidden stems, na yin and twelve-stage phase, the day master with its strength verdict, the element balance, the symbolic stars, the branch interactions and the ten-year Da Yun cycle. The app draws them: year on the right the way a chart is written, day column marked. The backend is one route and no dependencies, because that is the point: a browser cannot reach the API directly, so the key lives on the server.

Terminal window
git clone https://github.com/astroway/starter-bazi
cd starter-bazi && npm install
cp .env.example .env # your key goes here
npm run dev

Three things worth taking from it. Send a zone name and not an offset: Asia/Shanghai on 1990-05-15 is UTC+9, because China kept summer time from 1986 to 1991. Send a language: the default is Ukrainian, and an English page without one gets its element names in the wrong language. Send gender: Da Yun runs forward or backward depending on it and there is no neutral value.

Animals, elements, yin and yang, the palaces and the twelve stages are translated into 21 languages. Add ?lang=es and a *Name field appears next to the English token. The English fields never change: localisation adds, it does not replace.

Stems, branches, star names and na yin are deliberately not translated: their international form is pinyin next to the character.

Was this helpful?
Suggest an edit

Last updated: