> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sajuapi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 사주 계산

<Info>
  **v1 Enterprise API (Coming Soon)**

  이 엔드포인트는 Enterprise 버전에서 제공될 예정입니다.
  현재는 [v0 API](/api-reference/v0/overview)를 사용하세요.
</Info>

생년월일시를 기반으로 사주팔자(四柱八字)를 계산합니다. 이 API는 프로필을 생성하지 않고 순수한 계산 결과만 반환합니다.

<Note>
  프로필과 함께 사주를 저장하려면 [프로필 생성](/api-reference/profiles/create) API를 사용하세요. 이 API는 일회성 계산에 적합합니다.
</Note>

***

## Request Body 파라미터

<ParamField body="birth_year" type="integer" required>
  출생 연도입니다. 1900에서 2100 사이의 값이어야 합니다.
</ParamField>

<ParamField body="birth_month" type="integer" required>
  출생 월입니다. 1에서 12 사이의 값이어야 합니다.
</ParamField>

<ParamField body="birth_day" type="integer" required>
  출생 일입니다. 1에서 31 사이의 값이어야 합니다.
</ParamField>

<ParamField body="birth_hour" type="integer">
  출생 시입니다. 0에서 23 사이의 값이어야 합니다. 값을 넣지 않으면 시주(時柱) 없이 연주, 월주, 일주만 계산됩니다.
</ParamField>

<ParamField body="gender" type="string" required>
  성별입니다. `male` 또는 `female` 중 하나입니다. 대운(大運) 계산에 사용됩니다.
</ParamField>

<ParamField body="calendar_type" type="string" default="solar">
  달력 유형입니다. `solar`(양력) 또는 `lunar`(음력) 중 하나입니다.
</ParamField>

<ParamField body="include_analysis" type="boolean" default="true">
  상세 분석을 포함할지 여부입니다.
</ParamField>

***

## Response

### 성공

사주 계산에 성공하면 Saju 객체가 반환됩니다.

### 실패

| 상태 코드 | 에러 타입                  | 설명              |
| ----- | ---------------------- | --------------- |
| 400   | `validation_error`     | 요청 데이터가 유효하지 않음 |
| 401   | `authentication_error` | API 키가 유효하지 않음  |
| 429   | `rate_limited`         | 요청 한도 초과        |

***

## 요청 예시

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.sajuapi.dev/v1/calculations/saju \
    -H "X-API-Key: bs_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "birth_year": 1990,
      "birth_month": 3,
      "birth_day": 15,
      "birth_hour": 14,
      "gender": "male",
      "calendar_type": "solar",
      "include_analysis": true
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.sajuapi.dev/v1/calculations/saju', {
    method: 'POST',
    headers: {
      'X-API-Key': 'bs_live_xxx',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      birth_year: 1990,
      birth_month: 3,
      birth_day: 15,
      birth_hour: 14,
      gender: 'male',
      calendar_type: 'solar',
      include_analysis: true
    })
  });

  const saju = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.sajuapi.dev/v1/calculations/saju',
      headers={'X-API-Key': 'bs_live_xxx'},
      json={
          'birth_year': 1990,
          'birth_month': 3,
          'birth_day': 15,
          'birth_hour': 14,
          'gender': 'male',
          'calendar_type': 'solar',
          'include_analysis': True
      }
  )

  saju = response.json()
  ```
</CodeGroup>

***

## 응답 예시

```json theme={null}
{
  "pillars": {
    "year": {
      "stem": "경",
      "stem_hanja": "庚",
      "stem_meaning": "양금(陽金)",
      "branch": "오",
      "branch_hanja": "午",
      "branch_meaning": "말",
      "element": "metal",
      "hidden_stems": ["정", "기"]
    },
    "month": {
      "stem": "기",
      "stem_hanja": "己",
      "stem_meaning": "음토(陰土)",
      "branch": "묘",
      "branch_hanja": "卯",
      "branch_meaning": "토끼",
      "element": "earth",
      "hidden_stems": ["을"]
    },
    "day": {
      "stem": "병",
      "stem_hanja": "丙",
      "stem_meaning": "양화(陽火)",
      "branch": "인",
      "branch_hanja": "寅",
      "branch_meaning": "호랑이",
      "element": "fire",
      "hidden_stems": ["갑", "병", "무"]
    },
    "hour": {
      "stem": "을",
      "stem_hanja": "乙",
      "stem_meaning": "음목(陰木)",
      "branch": "미",
      "branch_hanja": "未",
      "branch_meaning": "양",
      "element": "wood",
      "hidden_stems": ["기", "정", "을"]
    }
  },
  "day_master": {
    "stem": "병",
    "hanja": "丙",
    "name": "병화",
    "element": "fire",
    "polarity": "yang",
    "description": "태양과 같이 밝고 뜨거운 기운입니다. 열정적이고 적극적인 성격을 가집니다.",
    "characteristics": [
      "밝고 명랑한 성격",
      "리더십이 강함",
      "열정적이고 진취적",
      "자기 표현력이 뛰어남"
    ]
  },
  "elements": {
    "wood": {
      "count": 2,
      "percentage": 25,
      "stems": ["을"],
      "branches": ["묘", "인"]
    },
    "fire": {
      "count": 3,
      "percentage": 37.5,
      "stems": ["병"],
      "branches": ["오"]
    },
    "earth": {
      "count": 1,
      "percentage": 12.5,
      "stems": ["기"],
      "branches": []
    },
    "metal": {
      "count": 1,
      "percentage": 12.5,
      "stems": ["경"],
      "branches": []
    },
    "water": {
      "count": 1,
      "percentage": 12.5,
      "stems": [],
      "branches": []
    }
  },
  "element_balance": {
    "strongest": "fire",
    "weakest": "water",
    "needed": ["water", "metal"],
    "excess": ["fire"]
  },
  "ten_year_cycles": [
    {
      "age_start": 1,
      "age_end": 10,
      "stem": "경",
      "branch": "진",
      "element": "metal",
      "description": "초년운"
    },
    {
      "age_start": 11,
      "age_end": 20,
      "stem": "신",
      "branch": "사",
      "element": "metal",
      "description": "청년운"
    }
  ],
  "analysis": {
    "personality": "병화 일주는 태양처럼 밝고 따뜻한 성격을 가집니다. 자신감이 넘치고 리더십이 강하며, 다른 사람들에게 영감을 주는 능력이 있습니다.",
    "strengths": [
      "강한 리더십과 카리스마",
      "밝고 긍정적인 에너지",
      "창의력과 표현력",
      "결단력과 추진력"
    ],
    "weaknesses": [
      "지나친 자신감으로 인한 독선",
      "인내심 부족",
      "감정 기복"
    ],
    "career_advice": "창의적인 분야, 리더십이 필요한 직종, 대중을 상대하는 직업에 적합합니다.",
    "relationship_advice": "수(水) 기운이 있는 사람과의 관계가 조화롭습니다."
  }
}
```

***

## Saju 객체

### 사주(四柱) 정보

| 필드              | 타입     | 설명                        |
| --------------- | ------ | ------------------------- |
| `pillars`       | object | 사주(四柱) 정보입니다.             |
| `pillars.year`  | object | 연주(年柱)입니다. 태어난 해의 기둥입니다.  |
| `pillars.month` | object | 월주(月柱)입니다. 태어난 달의 기둥입니다.  |
| `pillars.day`   | object | 일주(日柱)입니다. 태어난 날의 기둥입니다.  |
| `pillars.hour`  | object | 시주(時柱)입니다. 태어난 시간의 기둥입니다. |

### 기둥(柱) 정보

| 필드             | 타입     | 설명           |
| -------------- | ------ | ------------ |
| `stem`         | string | 천간(天干)입니다.   |
| `stem_hanja`   | string | 천간의 한자입니다.   |
| `branch`       | string | 지지(地支)입니다.   |
| `branch_hanja` | string | 지지의 한자입니다.   |
| `element`      | string | 오행입니다.       |
| `hidden_stems` | array  | 지장간(支藏干)입니다. |

### 일주(日柱) 정보

| 필드                       | 타입     | 설명                         |
| ------------------------ | ------ | -------------------------- |
| `day_master.stem`        | string | 일간(日干)입니다.                 |
| `day_master.name`        | string | 일간의 이름입니다.                 |
| `day_master.element`     | string | 일간의 오행입니다.                 |
| `day_master.polarity`    | string | 음양입니다. `yang` 또는 `yin`입니다. |
| `day_master.description` | string | 일간에 대한 설명입니다.              |

***

## 천간(天干)과 지지(地支)

### 천간 (10개)

| 천간 | 한자 | 오행   | 음양 |
| -- | -- | ---- | -- |
| 갑  | 甲  | 목(木) | 양  |
| 을  | 乙  | 목(木) | 음  |
| 병  | 丙  | 화(火) | 양  |
| 정  | 丁  | 화(火) | 음  |
| 무  | 戊  | 토(土) | 양  |
| 기  | 己  | 토(土) | 음  |
| 경  | 庚  | 금(金) | 양  |
| 신  | 辛  | 금(金) | 음  |
| 임  | 壬  | 수(水) | 양  |
| 계  | 癸  | 수(水) | 음  |

### 지지 (12개)

| 지지 | 한자 | 띠   | 오행   |
| -- | -- | --- | ---- |
| 자  | 子  | 쥐   | 수(水) |
| 축  | 丑  | 소   | 토(土) |
| 인  | 寅  | 호랑이 | 목(木) |
| 묘  | 卯  | 토끼  | 목(木) |
| 진  | 辰  | 용   | 토(土) |
| 사  | 巳  | 뱀   | 화(火) |
| 오  | 午  | 말   | 화(火) |
| 미  | 未  | 양   | 토(土) |
| 신  | 申  | 원숭이 | 금(金) |
| 유  | 酉  | 닭   | 금(金) |
| 술  | 戌  | 개   | 토(土) |
| 해  | 亥  | 돼지  | 수(水) |
