Neo Bazi Solutions 四柱推命 API 仕様書

エンドポイント

POST GET /api/v1/calculate

四柱推命の計算結果を取得します。

認証

APIキーによる認証が必要です。以下のいずれかの方法でAPIキーを提供してください。

Authorization ヘッダー (推奨):

Authorization: Bearer YOUR_API_KEY

クエリパラメータ:

?api_key=YOUR_API_KEY
📝 Note: APIキーはダッシュボードで確認できます。

リクエストパラメータ

以下のパラメータを application/json 形式のPOSTボディ、またはURLクエリパラメータとして含めてください。

パラメータ名 必須 説明
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キー。Authorizationヘッダーが優先されます。

レスポンス

成功した場合、以下の構造を持つJSONオブジェクトを返します。

{ "status": "success", "message": "API処理が正常に完了しました。", "credits_consumed": 10, "credits_remaining": 990, "result": { "input_date": "1990-05-15 14:30", "true_solar_time": "1990-05-15 14:47", "spring_date": "1990-05-05 16:27", "year_ganzhi": "庚午", "month_ganzhi": "辛巳", "day_ganzhi": "甲戌", "time_ganzhi": "辛未", "month_ganzhi_date": "1990-05-05 16:27", "month_ganzhi_biko": "立夏", "julian_day": 2448021.1159722, "day_ganzhi_details": { "gan": "甲", "zhi": "戌", "gan_gogyo": "木", "zhi_gogyo": "土", "gan_inyo": "陽", "zhi_inyo": "陽", "zogan": [ { "element": "戊", "gogyo": "土", "inyo": "陽", "tukan": "偏財" }, { "element": "辛", "gogyo": "金", "inyo": "陰", "tukan": "正官" }, { "element": "丁", "gogyo": "火", "inyo": "陰", "tukan": "傷官" } ] } }, "transaction_id": "txn_abc123...", "log_id": "log_xyz789..." }
📝 Note: result オブジェクト内のキーの順序は上記と異なる場合があります。

エラーレスポンス

エラーが発生した場合、以下の構造を持つJSONオブジェクトを返します。

{ "status": "error", "message": "エラーメッセージ" }

クレジット消費

API呼び出しごとに 10クレジット が消費されます。Enterpriseプランのユーザーはクレジットを消費しません。

サンプルコード

APIを利用するためのサンプルコードです。YOUR_API_KEY をご自身のAPIキーに置き換えてください。

cURL (Bash)

curl -X POST "https://api.nbs.jp/api/v1/calculate" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "year": 1990, "month": 5, "day": 15, "hour": 14, "minute": 30, "location": 139.6917 }'

JavaScript (Node.js)

const axios = require('axios'); const calculateBazi = async (birthDate, birthTime) => { try { const response = await axios.post('https://api.nbs.jp/api/v1/calculate', { year: 1990, month: 5, day: 15, hour: 14, minute: 30, location: 139.6917 }, { 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

import requests import json api_key = 'YOUR_API_KEY' url = 'https://api.nbs.jp/api/v1/calculate' data = { 'year': 1990, 'month': 5, 'day': 15, 'hour': 14, 'minute': 30, 'location': 139.6917 } headers = { 'Content-Type': 'application/json', 'Authorization': f'Bearer {api_key}' } 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)

備考

💡 Tips: 高精度な四柱推命計算のため、可能な限り正確な出生時刻と出生地の経度をご指定ください。