Back to Docs

BaZi (Four Pillars of Destiny)

POST/api/v1/chinese/bazi

Calculate 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/bazi

Available Features

Four Pillars

Year, Month, Day, Hour with Stems & Branches

Always
Ten Gods

Relationship of each stem to Day Master

Always
Hidden Stems

Inner energies within each branch

Always
Life Stages

12 Di Shi (growth stages) per pillar

Always
Luck Cycle

10-year Da Yun periods from birth

Always
Element Balance

Five elements point distribution

Always
Pinyin

Romanization for Chinese characters

include_pinyin
Stars (Shen Sha)

Tian Yi, Peach Blossom, etc.

include_stars
Interactions

Combinations, Clashes, Harms, Punishments

include_interactions
Professional

DM Strength, Structure, Yong Shen analysis

include_professional

Time Standard Options

civil (default)

Uses standard clock time directly. Best for modern births.

true_solar

Converts clock time to Local Mean Time (LMT) based on longitude.

true_solar_absolute

Uses astronomical true solar time with equation of time correction.

Request Parameters

ParameterTypeRequiredDescription
yearintegerYesYear of birth
monthintegerYesMonth of birth (1-12)
dayintegerYesDay of birth (1-31)
hourintegerYesHour of birth (0-23)
minuteintegerYesMinute of birth (0-59)
citystringYesCity name (used for coordinate lookup via /geo/search)
latfloatNoLatitude (-90 to 90). Optional: auto-resolved from city
lngfloatNoLongitude (-180 to 180). Optional: auto-resolved from city
sexstringYes'M' (male) or 'F' (female) - affects luck cycle direction
time_standardstringNo'civil' (default), 'true_solar', or 'true_solar_absolute'
include_pinyinbooleanNoInclude Pinyin romanization. Default: false
include_starsbooleanNoInclude Shen Sha (Symbolic Stars). Default: false
include_interactionsbooleanNoInclude Clashes, Combinations, Harms. Default: false
include_professionalbooleanNoInclude 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