This repo teaches AI coding agents (Cursor, Claude Code, Aider, Codex, Windsurf, RooCode, Gemini CLI) how to use the RoxyAPI BaZi chart endpoint, the Four Pillars of Destiny calculator.
- Method:
POST - URL:
https://roxyapi.com/api/v2/chinese-astrology/bazi/chart - Auth:
X-API-Keyheader - Domain:
chinese-astrology(one of 14+ in the RoxyAPI catalog) - Operation ID:
generateBaziChartmatches the SDK method name in camelCase - MCP tool:
post_chinese_astrology_bazi_chartonhttps://roxyapi.com/mcp/chinese-astrology
import { createRoxy } from '@roxyapi/sdk';
const roxy = createRoxy(process.env.ROXY_API_KEY!);
const { data, error } = await roxy.chineseAstrology.generateBaziChart({
body: {
date: '1990-06-15',
time: '23:30:00',
timezone: 'Asia/Shanghai',
dayBoundary: 'split-zi',
yearBoundary: 'li-chun',
hourClock: 'clock',
},
});import os
from roxy_sdk import create_roxy
roxy = create_roxy(os.environ["ROXY_API_KEY"])
result = roxy.chinese_astrology.generate_bazi_chart(
date="1990-06-15",
time="23:30:00",
timezone="Asia/Shanghai",
day_boundary="split-zi",
year_boundary="li-chun",
hour_clock="clock",
)This endpoint does not need coordinates, and neither does any other endpoint in this domain. A BaZi chart is read from the birth clock, so latitude is accepted only for consistency with the other birth data endpoints and changes nothing in the response. Do not call /location/search for this endpoint. Pass date, time and timezone directly, and prefer an IANA timezone name, which the server resolves to the offset in force on the birth date and echoes back as a number in birthData.timezone.
longitude is the one exception and it is conditional: it is required only when hourClock is local-mean or solar, which read the hour branch from the sun over the birth place. Sending either without longitude returns 400 with a message naming the field to add. With the default hourClock of clock, longitude is ignored.
date(string, required): birth date YYYY-MM-DD. Sets the year, month and day pillars. The year pillar turns at Beginning of Spring, not 1 January, and the month pillar turns at each of the twelve minor solar terms, not at a calendar month boundarytime(string, required): birth time HH:MM:SS, 24-hour. Sets the hour pillar. Each Earthly Branch covers two hours, so a birth within a few minutes of an odd hour can land in eithertimezone(number or IANA string, required): UTC offset (e.g. 8, 5.5) or IANA name (e.g. "Asia/Shanghai", "Asia/Taipei"). Server resolves the offset in force on the birth date and returns the resolved numberlatitude(number, optional): -90 to 90. Does not affect a BaZi chart. Defaults to 0longitude(number, optional): -180 to 180, positive East. Required whenhourClockislocal-meanorsolar, ignored when it isclockdayBoundary(string, optional):split-zi(default),midnightorearly-ziyearBoundary(string, optional):li-chun(default) orlunar-new-yearhourClock(string, optional):clock(default),local-meanorsolarlang(query, optional):en,tr,de,es,hi,pt,fr,ru,zh-Hans,zh-Hant
birthData: echoed input withtimezoneresolved to the decimal offset actually appliedconventions: the three school switches this result was computed under,dayBoundary,yearBoundaryandhourClock. Present on every response in the BaZi familypillars[]: the four pillars, year first, then month, day and hour. Each hasposition,id,number(1 to 60 in the sexagenary cycle),stem,branch,tenGod,hiddenStems[],naYin,naYinChineseandnaYinElementdayMaster: the day stem, which is the subject of the whole chart.stem,chinese,pinyin,element,polarityand anatureparagraphzodiacAnimal: animal of the year branch under the year boundary that was appliedfiveElements[]: one entry per phase withelement,count,levelandreadinginteractions[]: combinations, clashes, harms and punishments between the four pillars, each withtype,id,quality,positions[],members[]andmeaning. An empty array is normalsummary: one paragraph composed from the Day Master nature and the seasonal state of its element
- Coordinates are not part of a BaZi chart. Never call
/location/searchfor this endpoint, and never invent a latitude to satisfy a schema. - The three convention switches are the point of this endpoint. Send them explicitly when reproducing a specific chart, and store the returned
conventionsobject beside any chart you persist. Two calculators can produce different pillars for one birth and both be correct, andconventionsis what says which reading you are holding. dayBoundaryonly changes anything for a birth between 23:00 and 23:59. Underearly-zithe day pillar moves, which moves the Day Master, which re-labels every Ten God in the chart. Undermidnightonly the hour stem moves. Undersplit-zithe day holds and the hour stem is taken from the next day.yearBoundaryonly changes anything for a birth between Lunar New Year and Beginning of Spring, which is a few weeks each year.li-chunis the default on this endpoint. The folk zodiac route/chinese-astrology/zodiac/signdefaults tolunar-new-yearinstead, so the two can disagree for the same birth by design.hourClockoflocal-meanorsolarneedslongitude. Together they can move the hour branch by up to 75 minutes, which matters for a birth near an odd hour or near the edge of a wide time zone.- Every identifier is canonical English:
stem.id,branch.id,tenGod.id,conventions.*,type,quality,level,role,position,zodiacAnimal. Branch on those. With?lang=set, a*Localizedsibling appears for display only. ReadnameLocalized ?? nameand never compare against the translated value. hiddenStems[].roleis a rank,principalthenmiddlethenresidual. Some schools label the same three positions by function rather than by rank, which swaps two of the labels on the storage branches, so compare on rank.fiveElements[].countweighs the four stems and the four branch elements one point each and deliberately excludes hidden stems. A weighted total including hidden stems is a different quantity, so do not mix the two.- The endpoint is deterministic. The same birth moment under the same conventions always produces the same chart, so a result is safe to cache on your side and keyed by birth plus conventions.
POST /chinese-astrology/bazi/day-master(calculateDayMasterStrength): the strong or weak verdict, with the three classical factors published separately and summing intoscore, plus the favourable and unfavourable element listsPOST /chinese-astrology/bazi/luck-pillars(calculateLuckPillars): the ten year luck pillar timeline. Requiresgender, because the direction rule depends on itPOST /chinese-astrology/bazi/compatibility(calculateBaziCompatibility): two charts read against each other, with the Day Master relation, the cross interactions and a scorePOST /chinese-astrology/bazi/annual-forecast(calculateAnnualForecast): the Liu Nian yearly pillar against the natal chart, with thebenMingNianflagGET /chinese-astrology/calendar/solar-terms/{year}(listSolarTerms): the 24 solar terms with exact instants, which is what settles a month pillar boundary dispute
2026-Q3 against https://roxyapi.com/api/v2/openapi.json. Re-fetch the spec for ground truth before changing this file.
- Full catalog: https://roxyapi.com/AGENTS.md
- LLM index: https://roxyapi.com/llms.txt
- Methodology: https://roxyapi.com/methodology