BaZi (Four Pillars of Destiny)
/api/v1/chinese/baziCalculate the complete Four Pillars of Destiny (八字) chart based on birth date, time, and location. Includes Day Master analysis, Ten Gods, Life Stages, element balance, and optional professional features.
Full URL
https://astro-api-1qnc.onrender.com/api/v1/chinese/baziAvailable Features
Year, Month, Day, Hour with Stems & Branches
Relationship of each stem to Day Master
Inner energies within each branch
12 Di Shi (growth stages) per pillar
10-year Da Yun periods from birth
Five elements point distribution
Romanization for Chinese characters
Tian Yi, Peach Blossom, etc.
Combinations, Clashes, Harms, Punishments
DM Strength, Structure, Yong Shen analysis
Time Standard Options
Uses standard clock time directly. Best for modern births.
Converts clock time to Local Mean Time (LMT) based on longitude.
Uses astronomical true solar time with equation of time correction.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| year | integer | Yes | Year of birth |
| month | integer | Yes | Month of birth (1-12) |
| day | integer | Yes | Day of birth (1-31) |
| hour | integer | Yes | Hour of birth (0-23) |
| minute | integer | Yes | Minute of birth (0-59) |
| city | string | Yes | City name (used for coordinate lookup via /geo/search) |
| lat | float | No | Latitude (-90 to 90). Optional: auto-resolved from city |
| lng | float | No | Longitude (-180 to 180). Optional: auto-resolved from city |
| sex | string | Yes | 'M' (male) or 'F' (female) - affects luck cycle direction |
| time_standard | string | No | 'civil' (default), 'true_solar', or 'true_solar_absolute' |
| include_pinyin | boolean | No | Include Pinyin romanization. Default: false |
| include_stars | boolean | No | Include Shen Sha (Symbolic Stars). Default: false |
| include_interactions | boolean | No | Include Clashes, Combinations, Harms. Default: false |
| include_professional | boolean | No | Include DM Strength, Structure, Yong Shen. Default: false |
Sample Code
import requests
import json
url = "https://astro-api-1qnc.onrender.com/api/v1/chinese/bazi"
payload = {
"year": 1990,
"month": 5,
"day": 15,
"hour": 10,
"minute": 30,
"lat": 28.6139,
"lng": 77.2090,
"city": "New Delhi",
"sex": "M",
"time_standard": "civil",
"include_pinyin": True,
"include_stars": True,
"include_interactions": True,
"include_professional": True
}
headers = {
"Content-Type": "application/json",
"x-api-key": "YOUR_API_KEY"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())Response Data
{
"day_master": {
"stem": "丙",
"pinyin": "bǐng",
"info": {
"name": "Bing Fire",
"element": "Fire",
"polarity": "Yang"
}
},
"pillars": [
{
"label": "year",
"gan": "庚",
"gan_pinyin": "gēng",
"zhi": "午",
"zhi_pinyin": "wǔ",
"gan_zhi": "庚午",
"ten_gods": {
"stem": "Direct Wealth",
"hidden": ["Indirect Resource", "Rob Wealth"]
},
"life_stage": {
"name": "Bathing",
"name_zh": "沐浴",
"score": 5
},
"nayin": "路旁土",
"hidden_stems": ["丁", "己"]
},
{
"label": "month",
"gan": "辛",
"zhi": "巳",
"gan_zhi": "辛巳"
// ...
},
{
"label": "day",
"gan": "丙",
"zhi": "寅",
"gan_zhi": "丙寅"
// ...
},
{
"label": "hour",
"gan": "乙",
"zhi": "巳",
"gan_zhi": "乙巳"
// ...
}
],
"stars": [
{
"name": "Tian Yi Nobleman",
"name_zh": "天乙贵人",
"pillar": "day",
"description": "The greatest protective star"
},
{
"name": "Peach Blossom",
"name_zh": "桃花",
"pillar": "year",
"description": "Romance and popularity"
}
// ...
],
"interactions": [
{
"type": "Stem Combination",
"pillars": ["year", "hour"],
"stems": ["庚", "乙"],
"can_transform": true,
"transform_to": "Metal",
"interpretation": "Harmonious blend of elements"
},
{
"type": "Branch Clash",
"pillars": ["month", "hour"],
"branches": ["巳", "亥"],
"interpretation": "Fire-Water tension"
}
// ...
],
"xun_kong": {
"day_pillar_void": ["辰", "巳"],
"applies_to": ["natal", "luck", "annual"]
},
"professional": {
"dm_strength": "Strong",
"dm_strength_score": 0.64,
"structure": "Direct Resource Structure",
"yong_shen_candidates": ["Fire", "Wood"],
"interpretation": "High vitality with strong leadership potential"
},
"luck_cycle": {
"start_age_years": 4,
"pillars": [
{
"start_age": 4,
"start_year": 1994,
"end_age": 14,
"gan_zhi": "壬午",
"gan_pinyin": "rén",
"zhi_pinyin": "wǔ"
}
// ... 10-year cycles
]
},
"elements": {
"points": {
"Wood": 15,
"Fire": 75,
"Earth": 20,
"Metal": 45,
"Water": 5
}
},
"metadata": {
"engine_version": "1.3.0",
"ruleset": "Standard Traditional"
}
}Related Endpoints
Showcase Example
See what you can build with our BaZi API. our official open-source calculator demonstrates how to visualize the four pillars, luck cycles, and element balance using this exact endpoint.
View BaZi Calculator on GitHub