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.
A call in one line
Base URL · https://sagedestiny.comNo 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.
Access & quota
Four modes, decided by server configThe same endpoint behaves differently depending on how the deployment is configured. Which mode is active is always reported back in meta.mode.
| Mode | When it applies | Header required | meta.remaining |
|---|---|---|---|
| open | No keys configured — the hosted demo | none | null |
| keyed | Key list set, no counter store | X-Api-Key or Authorization: Bearer | null |
| free | Key is in the free list and a counter store is bound | same | requests left today |
| paid | Key is outside the free list | same | null (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.
Envelope & errors
One wrapper, two branchesSuccess 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_json | The body was not parseable JSON. |
|---|---|
| 400missing_date | A birth date was not supplied (/api/chart). |
| 400bad_time | Time out of range, or a date that does not exist. Message names the offending field. |
| 400missing_birth | Synastry needs a date for both a and b. |
| 401auth_required | Keyed deployment and no key was sent. |
| 401auth_invalid | Key sent but not in the configured list. |
| 422calc_failed | The inputs parsed but the calculation refused them — typically an impossible calendar date. |
| 429quota_exceeded | The 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.
Zi Wei Dou Shu
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
calendarstring | solar or lunar. Defaults to solar. Anything else falls back to solar silently. |
|---|---|
datestring | Required. YYYY-M-D with no zero padding — 1990-1-1, not 1990-01-01. Interpreted as a lunar date when calendar is lunar. |
timeIndexinteger | 0–12. 0 is the early Rat hour, 12 the late Rat hour, one value per double-hour. |
hourinteger | 0–23. An alternative to timeIndex; the server converts it. Supply one or the other — if both are present, timeIndex wins. |
genderstring | male / female, or the Chinese 男 / 女. Anything unrecognised is treated as male. |
isLeapMonthboolean | Only meaningful for lunar input: marks the month as an intercalary month. |
fixLeapboolean | Defaults to true: a leap month is reckoned as the following month, the traditional convention. |
langstring | zh-CN (default), zh-TW, or en-US. Governs the values, never the field names. |
Response · data
solarDate | Gregorian date echoed back, normalised. |
|---|---|
lunarDate | Lunar date, e.g. Lunar 1989-12-5 in English, 一九八九年腊月初五 in Chinese. |
chineseDate | Four pillars. English mode returns romanised stems and branches separated by ·; Chinese mode returns the characters. |
time · timeRange | The double-hour label and its clock span, e.g. early Rat hour / 00:00~01:00. |
fiveElementsClass | The element bureau that seeds the plate, e.g. water 2nd. |
soul · body | Soul and body masters by star name. |
zodiac · sign | Animal 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]
index | 0–11, positional. |
|---|---|
name | One 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 · earthlyBranch | The palace's stem and branch.earthlyBranch anchors the plate geometry. |
isBodyPalace · isOriginalPalace | Boolean 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 · boshi12 | The 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
name | Star name, localised. |
|---|---|
type | The 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. |
brightness | Brightness bracket such as [+1], or an empty string where brightness does not apply. |
mutagen | The 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], ... } }
Two-chart synastry
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
aobject | First person. Same fields as /api/chart: calendar, date (required), timeIndex or hour, gender, isLeapMonth. |
|---|---|
bobject | Second person, identical shape. |
langstring | zh-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 · b | Compact 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. |
scores | overall, 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.
Da Liu Ren
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
yearinteger | Required. Gregorian, 1900–2100. |
|---|---|
month · dayinteger | Required. Gregorian month and day; the lunar date and pillars are derived. |
hourinteger | Required. 0–23. |
minuteinteger | 0–59, defaults to 0. Used only to echo the moment back. |
questionstring | Optional. The matter being asked; echoed in data.question and never interpreted. |
langstring | zh-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
input | Year, month, day, hour, minute as received. |
|---|---|
solar · lunar | The moment in both calendars. |
bazi | { year, month, day, hour } — the four pillars of the moment, as stem-branch pairs. |
shiZhi | The 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. |
sanChuan | chu, zhong, mo, each { zhi, land, dun, jiang } — plus keTi, special, kind describing the structure that was found. |
question | The 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.
Language
Values localise, keys never doField 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.
Limits
What the edge will and will not doThere 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.
Terms of use
Short, and meantThese 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.