Skip to main content
POST
https://sajuapi.dev
/
api
/
saju
사주 계산
curl --request POST \
  --url https://sajuapi.dev/api/saju \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "year": 123,
  "month": 123,
  "day": 123,
  "hour": 123,
  "gender": "<string>"
}
'
생년월일시를 기반으로 사주팔자를 계산합니다.
권장: 클라이언트에서 SajuCalculator.js를 사용하여 계산하는 것이 더 효율적입니다. 이 엔드포인트는 서버사이드 계산이 필요한 경우에만 사용하세요.

Request Body

year
integer
required
출생 연도입니다. (예: 1990)
month
integer
required
출생 월입니다. (1-12)
day
integer
required
출생 일입니다. (1-31)
hour
integer
출생 시입니다. (0-23) 선택 사항입니다.
gender
string
required
성별입니다. male 또는 female입니다.

Response

성공

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

요청 예시

const response = await fetch('/api/saju', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    year: 1990,
    month: 3,
    day: 15,
    hour: 14,
    gender: 'male'
  })
});

const saju = await response.json();

응답 예시

{
  "pillars": {
    "year": {
      "stem": {
        "kr": "경",
        "hangul": "경",
        "cn": "庚",
        "element": "metal",
        "elementKr": "금",
        "yinYang": "양",
        "index": 6
      },
      "branch": {
        "kr": "오",
        "hangul": "오",
        "cn": "午",
        "element": "fire",
        "elementKr": "화",
        "animal": "말",
        "index": 6
      },
      "fullKr": "경오",
      "fullCn": "庚午"
    },
    "month": {
      "stem": { "hangul": "기", "element": "earth" },
      "branch": { "hangul": "묘", "element": "wood" },
      "fullKr": "기묘",
      "fullCn": "己卯"
    },
    "day": {
      "stem": { "hangul": "병", "element": "fire" },
      "branch": { "hangul": "인", "element": "wood" },
      "fullKr": "병인",
      "fullCn": "丙寅"
    },
    "hour": {
      "stem": { "hangul": "을", "element": "wood" },
      "branch": { "hangul": "미", "element": "earth" },
      "fullKr": "을미",
      "fullCn": "乙未"
    }
  },
  "dayMaster": {
    "name": "병화",
    "element": "fire",
    "elementKr": "화",
    "yinYang": "양",
    "hangul": "병",
    "hanja": "丙"
  },
  "elements": {
    "wood": 3,
    "fire": 2,
    "earth": 2,
    "metal": 1,
    "water": 0
  },
  "dominantElement": "wood",
  "weakestElement": "water",
  "zodiac": "말",
  "gender": "male"
}

SajuResult 객체

필드타입설명
pillarsobject사주 네 기둥 (년주, 월주, 일주, 시주)입니다.
dayMasterobject일주 천간 정보입니다.
elementsobject오행별 개수입니다.
dominantElementstring가장 강한 오행입니다.
weakestElementstring가장 약한 오행입니다.
zodiacstring띠입니다.
genderstring성별입니다.

천간 (十天干)

한글한자오행음양
목(木)
목(木)
화(火)
화(火)
토(土)
토(土)
금(金)
금(金)
수(水)
수(水)

클라이언트 계산 (권장)

서버 API 대신 클라이언트에서 직접 계산하는 것이 더 효율적입니다.
<!-- SajuCalculator 로드 -->
<script src="/js/saju-calculator.js"></script>
// 클라이언트에서 계산
const saju = SajuCalculator.calculate({
  year: 1990,
  month: 3,
  day: 15,
  hour: 14,
  gender: 'male'
});

// 운세 API에 직접 사용
const fortune = await fetch('/api/daily-fortune', {
  method: 'POST',
  body: JSON.stringify({ saju, userName: '김철수', date: '2025-01-16' })
});
클라이언트 계산 시 서버 왕복이 줄어들어 응답 속도가 빨라집니다.