Neo Bazi Solutions 四柱推命 API 仕様書
エンドポイント
GET
POST
https://api.nbs.jp/v1/calculate
四柱推命の計算結果を取得します。
認証
APIキーによる認証が必要です。以下のいずれかの方法でAPIキーを提供してください。
方法1: URLパラメーター (GET/POST リクエスト) - 最も確実:
?api_key=YOUR_API_KEY&year=1974&month=10&day=3&hour=11&location=139.75
方法2: JSONボディ内 (POST リクエスト) - 推奨:
{
"api_key": "YOUR_API_KEY",
"year": 1974,
"month": 10,
"day": 3,
"hour": 11,
"location": 139.75
}
方法3: Authorization ヘッダー (GET/POST リクエスト):
Authorization: Bearer YOUR_API_KEY
方法4: X-API-Key ヘッダー (GET/POST リクエスト):
X-API-Key: YOUR_API_KEY
📝 Note: APIキーはダッシュボードで確認できます。
⚠️ 重要: ブラウザから直接アクセスする場合、AuthorizationとX-API-Keyヘッダーが空になるため、URLパラメータまたはJSONボディでのAPIキー送信をお勧めします。JavaScript(fetch/XMLHttpRequest)からはすべての方法が正常に動作します。
リクエストパラメータ
以下のパラメータを送信してください。GETリクエストの場合はURLクエリパラメータ、POSTリクエストの場合はapplication/json
形式のリクエストボディとして送信します。
パラメータ名 |
型 |
必須 |
説明 |
year |
integer |
必須 |
西暦年 (例: 1990) |
month |
integer |
必須 |
月 (1-12) (例: 5) |
day |
integer |
必須 |
日 (1-31) (例: 15) |
location |
float |
必須 |
経度 (東経を正の値で指定) (例: 139.6917) |
hour |
integer |
任意 |
時 (0-23)。time パラメータが指定されている場合は無視されます。 |
minute |
integer |
任意 |
分 (0-59)。time パラメータが指定されている場合は無視されます。デフォルトは0です。 |
time |
string |
任意 |
時刻を HH:MM 形式で指定します (例: "14:30")。hour , minute より優先されます。時刻が指定されない場合、デフォルトで "12:00" が使用されます。 |
api_key |
string |
任意 |
APIキー。URLパラメータまたはJSONボディで送信します。ヘッダー認証より優先されます。 |
レスポンス
成功した場合、以下の構造を持つJSONオブジェクトを返します。
{
"status": "success",
"message": "API処理が正常に完了しました。",
"credits_consumed": 10,
"credits_remaining": 1120,
"monthly_credits": 1110,
"auto_credits": 10,
"credits_used_from": {
"monthly": 10,
"auto": 0
},
"autocharge_info": {
"success": true,
"message": "Total credits above threshold",
"debug": {
"monthly_credits": 1120,
"auto_credits": 10,
"total_credits": 1130,
"threshold": 100
}
},
"result": {
"input_date": "1974-10-03 11:00",
"input_longitude": 139.75,
"true_solar_time": "1974-10-03 11:19",
"spring_date": "1974-02-04 14:00",
"year_ganzhi": "甲寅",
"month_ganzhi": "癸酉",
"day_ganzhi": "丁丑",
"time_ganzhi": "丙午",
"month_ganzhi_date": "1974-09-08 09:45",
"month_ganzhi_biko": "白露(黄経165°)",
"julian_day": 2442323,
"day_ganzhi_details": {
"number": 14,
"element": "火",
"yin_yang": "陰-",
"heavenly_stem": "丁",
"earthly_branch_group": "申酉",
"star": "天庫星",
"animal": "ひつじ"
},
"ten_gods": {
"year": "印綬",
"month": "偏官",
"time": "劫財"
},
"zokan": {
"year": "甲",
"month": "辛",
"day": "己",
"time": "丁"
},
"zokan_ten_gods": {
"year": "印綬",
"month": "偏財",
"day": "食神",
"time": "比肩"
},
"juniun": {
"year": "死",
"month": "長生",
"day": "墓",
"time": "建禄"
},
"nayin": [],
"gogyo_balance": {
"木": 2,
"火": 3,
"土": 1,
"金": 1,
"水": 1
},
"summary": {
"day_master": "丁丑",
"element": "火",
"strength": "中",
"fortune_score": 70,
"personality_traits": [
"繊細"
]
}
},
"transaction_id": null,
"log_id": "1751616830"
}
📝 Note: result
オブジェクト内のキーの順序は上記と異なる場合があります。
エラーレスポンス
エラーが発生した場合、以下の構造を持つJSONオブジェクトを返します。
{
"status": "error",
"message": "エラーメッセージ"
}
クレジット消費
API呼び出しごとに 10クレジット が消費されます。Enterpriseプランのユーザーはクレジットを消費しません。
サンプルコード
APIを利用するためのサンプルコードです。YOUR_API_KEY
をご自身のAPIキーに置き換えてください。
cURL (Bash) - GET リクエスト
curl "https://api.nbs.jp/v1/calculate?api_key=YOUR_API_KEY&year=1974&month=10&day=3&hour=11&location=139.75"
cURL (Bash) - POST リクエスト (推奨)
curl -X POST "https://api.nbs.jp/v1/calculate" \
-H "Content-Type: application/json" \
-d '{
"api_key": "YOUR_API_KEY",
"year": 1974,
"month": 10,
"day": 3,
"hour": 11,
"location": 139.75
}'
cURL (Bash) - POST リクエスト (ヘッダー認証)
curl -X POST "https://api.nbs.jp/v1/calculate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"year": 1974,
"month": 10,
"day": 3,
"hour": 11,
"location": 139.75
}'
JavaScript (Node.js) - GET リクエスト
const axios = require('axios');
const calculateBazi = async () => {
try {
const response = await axios.get('https://api.nbs.jp/v1/calculate', {
params: {
api_key: 'YOUR_API_KEY',
year: 1974,
month: 10,
day: 3,
hour: 11,
location: 139.75
}
});
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
throw error;
}
};
calculateBazi()
.then(result => console.log(result))
.catch(error => console.error(error));
JavaScript (Node.js) - POST リクエスト
const axios = require('axios');
const calculateBazi = async () => {
try {
const response = await axios.post('https://api.nbs.jp/v1/calculate', {
year: 1974,
month: 10,
day: 3,
hour: 11,
location: 139.75
}, {
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
throw error;
}
};
calculateBazi()
.then(result => console.log(result))
.catch(error => console.error(error));
Python - GET リクエスト
import requests
api_key = 'YOUR_API_KEY'
url = 'https://api.nbs.jp/v1/calculate'
params = {
'api_key': api_key,
'year': 1974,
'month': 10,
'day': 3,
'hour': 11,
'location': 139.75
}
response = requests.get(url, params=params)
if response.status_code == 200:
result = response.json()
print(json.dumps(result, indent=2, ensure_ascii=False))
else:
print(f"APIリクエストエラー: {response.status_code}")
print(response.text)
Python - POST リクエスト
import requests
import json
api_key = 'YOUR_API_KEY'
url = 'https://api.nbs.jp/v1/calculate'
data = {
'year': 1974,
'month': 10,
'day': 3,
'hour': 11,
'location': 139.75
}
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
result = response.json()
print(json.dumps(result, indent=2, ensure_ascii=False))
else:
print(f"APIリクエストエラー: {response.status_code}")
print(response.text)
備考
現在サポート中の機能
- 真太陽時は、入力された日時と経度に基づいて計算されます。日本標準時子午線(東経135度)からの経度差により時間が補正されます。
- 時柱は、真太陽時と日干支に基づいて計算されます。
- 二十四節気データは国立天文台の正式データを使用し、1900年から2100年まで対応しています。
- 十神(じっしん):日干を基準とした他の天干との五行関係。年柱・月柱・時柱の十神を提供。
- 蔵干(ぞうかん):地支に含まれる天干の情報。
- 蔵干通変星:蔵干に基づく十神の情報。
- 十二運(じゅうにうん):日干の強弱を表す十二種類の運勢。
- 納音(なっちん):現在は配列として提供(詳細実装は今後拡張予定)。
- 五行バランス:木・火・土・金・水の各要素の数値。
- 基本サマリー:日主、五行要素、強弱、運勢スコア、基本性格特性。
今後拡張予定の機能
- 神殺(しんさつ)詳細:天乙貴人、文昌貴人、魁罡、桃花、華蓋、空亡など、特殊な星の詳細分析。
- 納音詳細:60干支を五行の音律により30対に分類した詳細な性質と意味の解説。
- 総合分析:十神・納音・神殺の情報を統合した運勢指標、性格特性、適職分野の詳細分析。
- 年運・月運計算:大運・流年・流月による時期別運勢分析。
- 相性診断:複数の命式を比較した相性分析機能。
💡 Tips: 高精度な四柱推命計算のため、可能な限り正確な出生時刻と出生地の経度をご指定ください。