Sage Destiny Chinese metaphysics · JSON

API reference

Three endpoints,
one envelope.

Every response is JSON, every request is a POST, and every field below was taken from a live call. Nothing here is aspirational — if it is documented, it is returned.

00

A call in one line

Base URL · https://sagedestiny.com

No SDK, no auth dance while the service is in open mode. Send JSON, get JSON back. CORS is open to all origins, so a browser fetch works as-is.

# a twelve-palace chart for 1 Jan 1990, noon
curl -X POST https://sagedestiny.com/api/chart \
  -H "Content-Type: application/json" \
  -d '{"calendar":"solar","date":"1990-1-1","hour":12,"gender":"male","lang":"en-US"}'

Every endpoint accepts OPTIONS for preflight and returns a short usage note on GET, so you can paste the URL into a browser to check it is alive. The documented host is a placeholder; swap in the production domain once it is bound.

01

Access & quota

Four modes, decided by server config

The same endpoint behaves differently depending on how the deployment is configured. Which mode is active is always reported back in meta.mode.

ModeWhen it appliesHeader requiredmeta.remaining
openNo keys configured — the hosted demononenull
keyedKey list set, no counter storeX-Api-Key or Authorization: Bearernull
freeKey is in the free list and a counter store is boundsamerequests left today
paidKey is outside the free listsamenull (unmetered)

Send the key in either header — X-Api-Key: <key> is the shorter form, and Authorization: Bearer <key> is the conventional one. Free-tier counters reset at UTC midnight and are stored per key per day.

curl -X POST https://sagedestiny.com/api/chart \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: $OURANIC_KEY" \
  -d '{"date":"1990-1-1","hour":12,"gender":"male","lang":"en-US"}'

Key hygiene. Keys are compared server-side only; they are never echoed in a response or logged in a payload. Treat one key as one client, and rotate it if it appears in a public repository.

02

Envelope & errors

One wrapper, two branches

Success and failure never mix. Check ok first, then read data or error — the status code alone tells you the class of failure.

// success
{ "ok": true, "meta": { "engine": "iztro", "version": "2.6.5",
  "mode": "open", "remaining": null }, "data": { ... } }

// failure
{ "ok": false, "error": { "code": "missing_date", "message": "缺少 date" } }

meta carries the engine that produced the answer, its version, the access mode and the day's remaining count when there is one. meta.rule appears on synastry and Liu Ren, naming the rule set used.

400bad_jsonThe body was not parseable JSON.
400missing_dateA birth date was not supplied (/api/chart).
400bad_timeTime out of range, or a date that does not exist. Message names the offending field.
400missing_birthSynastry needs a date for both a and b.
401auth_requiredKeyed deployment and no key was sent.
401auth_invalidKey sent but not in the configured list.
422calc_failedThe inputs parsed but the calculation refused them — typically an impossible calendar date.
429quota_exceededThe key's casts are spent. Buy a block on the pricing page; paid keys are never metered.

Error message strings are diagnostic, written in Chinese by the engine. Branch on code, never on the message.

03

Zi Wei Dou Shu

post/api/chart

A full twelve-palace plate: stems and branches per palace, major and minor stars with brightness, the four transformations, decade ranges, and the soul and body masters.

Request

calendarstringsolar or lunar. Defaults to solar. Anything else falls back to solar silently.
datestringRequired. YYYY-M-D with no zero padding — 1990-1-1, not 1990-01-01. Interpreted as a lunar date when calendar is lunar.
timeIndexinteger0–12. 0 is the early Rat hour, 12 the late Rat hour, one value per double-hour.
hourinteger0–23. An alternative to timeIndex; the server converts it. Supply one or the other — if both are present, timeIndex wins.
genderstringmale / female, or the Chinese 男 / 女. Anything unrecognised is treated as male.
isLeapMonthbooleanOnly meaningful for lunar input: marks the month as an intercalary month.
fixLeapbooleanDefaults to true: a leap month is reckoned as the following month, the traditional convention.
langstringzh-CN (default), zh-TW, or en-US. Governs the values, never the field names.

Response · data

solarDateGregorian date echoed back, normalised.
lunarDateLunar date, e.g. Lunar 1989-12-5 in English, 一九八九年腊月初五 in Chinese.
chineseDateFour pillars. English mode returns romanised stems and branches separated by ·; Chinese mode returns the characters.
time · timeRangeThe double-hour label and its clock span, e.g. early Rat hour / 00:00~01:00.
fiveElementsClassThe element bureau that seeds the plate, e.g. water 2nd.
soul · bodySoul and body masters by star name.
zodiac · signAnimal year and Western sun sign, both lower-case in English mode.
palaces[12]Always twelve, in fixed order starting at the life palace's position. See below.

Response · palaces[i]

index0–11, positional.
nameOne of twelve palace names, spelled as the engine spells them — parents, siblings, spouse, wealth, career and so on. Do not hard-code the list; key off index when you need a stable handle.
heavenlyStem · earthlyBranchThe palace's stem and branch.earthlyBranch anchors the plate geometry.
isBodyPalace · isOriginalPalaceBoolean flags marking the body palace and the original palace.
majorStars[] · minorStars[] · adjectiveStars[]Three tiers of stars. Each item is a star object; a palace can legitimately carry none.
changsheng12 · boshi12The twelve-stage and twelve-god cycles, one label per palace.
decadal{ range: [start, end], heavenlyStem, earthlyBranch } — the decade that rules this palace.
ages[]Ten small-limit ages falling in this palace.

Response · star object

nameStar name, localised.
typeThe star's class as the engine labels it: major for the fourteen majors, then finer classes among the rest — soft, tianma, flower, adjective. Which array a star sits in is what groups it; this value refines it.
brightnessBrightness bracket such as [+1], or an empty string where brightness does not apply.
mutagenThe transformation carried by the star, or an empty string. In Chinese mode these read 禄 权 科 忌.
{ "index": 0, "name": "parents", "heavenlyStem": "bing",
  "earthlyBranch": "yin", "isBodyPalace": false,
  "majorStars": [{ "name": "Advisor", "type": "major",
                   "brightness": "[+1]", "mutagen": "" }],
  "changsheng12": "sick", "decadal": { "range": [112, 121], ... } }
04

Two-chart synastry

post/api/heming

Builds a plate for each person, then compares element phase, life-palace stars, spouse-palace condition, the triangular houses and where the four transformations land. Output is six scores, six reasons, four pieces of advice.

Request

aobjectFirst person. Same fields as /api/chart: calendar, date (required), timeIndex or hour, gender, isLeapMonth.
bobjectSecond person, identical shape.
langstringzh-CN (default) or en-US. Applies to both charts and all prose.
curl -X POST https://sagedestiny.com/api/heming \
  -H "Content-Type: application/json" \
  -d '{"a":{"date":"1990-1-1","timeIndex":6,"gender":"male"},
      "b":{"date":"1992-5-20","timeIndex":4,"gender":"female"},
      "lang":"en-US"}'

Response · data

a · bCompact summaries: solarDate, lunarDate, chineseDate, fiveElementsClass, soul, body.
a.ming{ name, branch, stars[] } — the life palace, its branch and its star names.
a.spousePalace{ branch, stars[] } — where the spouse question is read from.
a.keyStars[]Four stars that carry weight in the comparison.
scoresoverall, emotional, communication, spouse, finance, stability — integers on a 0–100 scale.
reasons[]Six items, one per dimension: { dim, text, score }. score is the signed contribution, and the six add up to the offset from a neutral 50.
advice[]Four sentences of plain prose, chosen by the overall band rather than generated.

Chinese chineseDate and palace branches stay as characters even in en-US — the synastry engine computes internally in Chinese and translates the labels it exposes. Read ming.branch as an earthly branch, not as a word.

05

Da Liu Ren

post/api/liuren

Casts a plate for a given moment: the heaven plate over the earth plate, four lessons, three transmissions, the void branches, and a short reading naming the structure and what it implies.

Request

yearintegerRequired. Gregorian, 1900–2100.
month · dayintegerRequired. Gregorian month and day; the lunar date and pillars are derived.
hourintegerRequired. 0–23.
minuteinteger0–59, defaults to 0. Used only to echo the moment back.
questionstringOptional. The matter being asked; echoed in data.question and never interpreted.
langstringzh-CN (default) or en-US. Translates the reading, not the plate.
curl -X POST https://sagedestiny.com/api/liuren \
  -H "Content-Type: application/json" \
  -d '{"year":2025,"month":3,"day":8,"hour":10,"minute":30,"lang":"en-US"}'

Response · data

inputYear, month, day, hour, minute as received.
solar · lunarThe moment in both calendars.
bazi{ year, month, day, hour } — the four pillars of the moment, as stem-branch pairs.
shiZhiThe hour branch that seeds the plate.
yueJiang{ zhi, name, qi, jie } — the monthly general, its branch, and the two solar terms that bracket the change.
gui{ zhi, land, forward, isDay } — where the noble sits, whether the plate turns forward, and day/night.
kongWang[]Two void branches.
pan[12]Twelve earth positions: { land, god, jiang, dun } — earth branch, the general on it, the heavenly branch above, and its hidden stem.
siKe[4]Four lessons: { no, xia, shang, relation } — number, lower, upper, and the克 relation between them.
sanChuanchu, zhong, mo, each { zhi, land, dun, jiang } — plus keTi, special, kind describing the structure that was found.
questionThe question as received, or null.
reading{ keTi, special, desc, sanChuanText } — the structure name, its label, one sentence of interpretation, and the three transmissions spelled out.

In en-US, reading and its keTi are translated, while plate internals — branches, generals, hidden stems, the siKe.relation strings — remain Chinese. That is deliberate: those are the symbols a practitioner reads, not prose.

06

Language

Values localise, keys never do

Field names are identical in every language. Only the values move, and only where a value is a name rather than a symbol.

/api/chart and /api/heming translate star names, palace names, element bureaus, zodiac and the four transformations. /api/liuren translates its reading but keeps the plate in Chinese characters, because the plate is a notation rather than a sentence.

zh-TW is accepted on /api/chart and returns traditional characters. The other two endpoints take zh-CN or en-US; anything else is coerced to zh-CN, and the resolved language is reported in meta.lang.

07

Limits

What the edge will and will not do

There is no request-per-second throttle: the plate calculations are sub-millisecond and run in the worker. The only ceiling is the free allowance — three casts per key, counted once, never reset.

The supported range is 1900–2100 for every calendar calculation; outside it, expect bad_time. Each call is stateless — the same request returns the same plate forever, so results are safe to cache on your side. Body size is bounded by the platform's 100 KB request limit, which no legitimate chart request approaches.

If you need bulk casting, cast the plates once and store them; the marginal cost of a hundred charts is the hundred calls, not the arithmetic.

08

Terms of use

Short, and meant

These instruments are for entertainment and cultural study. Output is a reading of a classical notation, not advice: it is not medical, legal, financial or psychological guidance, and no decision of consequence should rest on it.

Results are computed deterministically from the inputs you send; we make no warranty that a given school of practice would agree with every interpretation. Do not resell raw API access as your own product without written permission. Attribution is appreciated and never required for the JSON itself.