샘플 코드
키는 메인 페이지에서 발급. 모든 요청에 X-API-Key 헤더.
토정비결 — 생년월일 → 괘·원문·독음
cURL
curl -X POST https://api.lunaple.kr/v1/tojeong/gwae \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"birth":"1988-05-14","calendar":"solar","targetYear":2026}'
JavaScript (fetch)
const r = await fetch('https://api.lunaple.kr/v1/tojeong/gwae', {
method: 'POST',
headers: { 'X-API-Key': KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ birth: '1988-05-14', calendar: 'solar', targetYear: 2026 })
});
const { data } = await r.json();
console.log(data.calc.gwaeId, data.gwae.title.reading); // "751" "분주분망무소득지의"
console.log(data.gwae.yearly[0]); // "삼일지정(三日之程) 일일행지(一日行之)"
console.log(data.gwae.monthly['3']); // 3월 3구절
Python (requests)
import requests
r = requests.post("https://api.lunaple.kr/v1/tojeong/gwae",
headers={"X-API-Key": KEY},
json={"birth": "1995-08-15", "calendar": "lunar", "leapMonth": True, "targetYear": 2026})
d = r.json()["data"]
print(d["calc"]["gwaeId"], d["calc"]["yearGapja"], d["calc"]["monthGapja"], d["calc"]["dayGapja"])
for m, lines in d["gwae"]["monthly"].items():
print(m, "월:", " / ".join(lines))
응답 구조
| 필드 | 설명 |
|---|---|
calc.gwaeId | 괘 번호 3자리 (상괘1-8·중괘1-6·하괘1-3) |
calc.yearGapja / monthGapja / dayGapja | 대상연 태세·월건·일진 (음력 정월 기준 60갑자) |
calc.lunar.leap | 윤달 출생 여부 (윤달은 본달로 작괘) |
gwae.title | {hanja, reading} 괘 표제 |
gwae.yearly[9] / monthly["1".."12"][3] | 원문 구절. 기본 "독음(漢字)" 병기, reading:false면 한자만 |
source | 원문 출처·계산 라이브러리·독음표 버전 |
LLM 해석 붙이기 (권장 패턴)
// 1) 결정론 값은 API에서
const { data } = await (await fetch(API, …)).json();
// 2) 해석은 당신의 LLM으로 — 숫자·괘는 절대 바꾸지 말라고 지시
const prompt = `다음은 토정비결 ${data.calc.gwaeId}괘(${data.gwae.title.reading})의 원문입니다.
연운: ${data.gwae.yearly.join(' / ')}
3월: ${data.gwae.monthly['3'].join(' / ')}
괘 번호와 원문은 바꾸지 말고, 20대 여성 독자에게 친근한 말투로 3월 운세를 4문장으로 풀어주세요.`;
작명 — 성·이름 한자 → 수리·오격·점수
curl -X POST https://api.lunaple.kr/v1/name/analyze \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"surname":"金","given":"民奎"}'
// 표기음이 사전과 다르면(두음 등) hangul 지정
{ "surname": [{"hanja":"李","hangul":"이"}], "given": [{"hanja":"瑞"},{"hanja":"英"}] }
응답 result: 오격(천·인·지·외·총), 오격수리(81수리 길흉), 음양, 발음오행, 점수, 등급, 출처. 미등재 한자는 422 CHAR_NOT_FOUND — GET /v1/name/char/{한자}로 사전 확인.
오류·한도
| 코드 | 의미 |
|---|---|
| 401 NO_API_KEY / 403 INVALID_API_KEY | 키 누락·폐기·비활성 |
| 429 RATE_LIMIT | 분당 한도 (Sandbox 10 / Starter 60 / Growth 120) |
| 429 QUOTA_EXCEEDED | 월 한도. 응답 헤더 X-RateLimit-Remaining-Month로 잔여 확인 |
| 400 BAD_BIRTH / BAD_GWAE_ID / BAD_INPUT | 입력 형식 |
| 422 CALC_ERROR / CHAR_NOT_FOUND | 계산 불가(출생 전 연도 등) · 인명용 한자 미등재 |
전체 스키마: openapi.yaml · 문의 support@yujinnetwork.com