House direction by birth year API
Life palace (cung mệnh) by lunar birth year and sex, East / West group, the four good and four bad directions, a facing check and couple compatibility.
Implements the Eight Mansions school (Bát trạch) used in Vietnamese real estate: from the lunar birth year and the sex it returns the life palace (cung phi: Khảm, Khôn, Chấn, Tốn, Càn, Đoài, Cấn, Ly), its element and East / West group, and the eight directions with their stars: Sinh khí, Thiên y, Diên niên and Phục vị (good), Họa hại, Ngũ quỷ, Lục sát and Tuyệt mệnh (bad), each with its compass range.
Send a solar birth_date and the lunar year is computed (people born before Tết belong to the previous year). Add facing (degrees or a direction) to check a door, house or desk, and partner_year to compare a couple’s palaces and find their common good directions.
This is folk belief, given as cultural reference: it has no scientific basis. The formula is the common one (men: (2 − year) mod 9, women: (year − 5) mod 9, 5 → Khôn for men, Cấn for women).
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
year | query | number | no | Lunar birth year (or send birth_date). | |
birth_date | query | string | no | Solar birth date YYYY-MM-DD; the lunar year is computed. | |
sex | query | string | yes | male / female (or nam / nữ). | |
facing | query | string | no | Direction to check: degrees (0 = north) or N, NE, Đông Nam… | |
partner_year / partner_birth_date, partner_sex | query | string | no | Partner for couple compatibility. |
Example
curl "https://apibox.io.vn/v1/vn-house-direction?year=1990&sex=male&facing=135" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/vn-house-direction?year=1990&sex=male&facing=135', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/vn-house-direction?year=1990&sex=male&facing=135",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/vn-house-direction?year=1990&sex=male&facing=135');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"lunar_year": 1990,
"can_chi": "Canh Ngọ",
"sex": "male",
"palace": "Khảm",
"element": "Thủy",
"group": "Đông tứ mệnh",
"group_en": "East group",
"directions": [
{
"star": "Sinh khí",
"star_en": "Vitality",
"good": true,
"direction": "SE",
"direction_vi": "Đông Nam",
"direction_en": "South-east",
"degrees": [
112.5,
157.5
],
"meaning_vi": "tốt nhất: tài lộc, danh tiếng"
},
{
"star": "Thiên y",
"star_en": "Heavenly doctor",
"good": true,
"direction": "E",
"direction_vi": "Đông",
"direction_en": "East",
"degrees": [
67.5,
112.5
],
"meaning_vi": "sức khỏe, quý nhân"
},
{
"star": "Tuyệt mệnh",
"star_en": "Total loss",
"good": false,
"direction": "SW",
"direction_vi": "Tây Nam",
"direction_en": "South-west",
"degrees": [
202.5,
247.5
],
"meaning_vi": "xấu nhất: bệnh tật, phá sản"
}
],
"good_directions": [
"Đông Nam",
"Đông",
"Nam",
"Bắc"
],
"bad_directions": [
"Tây",
"Đông Bắc",
"Tây Bắc",
"Tây Nam"
],
"facing": {
"direction": "SE",
"direction_vi": "Đông Nam",
"star": "Sinh khí",
"star_en": "Vitality",
"good": true,
"meaning_vi": "tốt nhất: tài lộc, danh tiếng"
},
"school": "Bát trạch (Eight Mansions), cung phi by lunar birth year; the house direction is the direction the main door faces",
"disclaimer": "Folk belief (phong thủy), for cultural reference only; it has no scientific basis."
}
Use cases
- Add “suits which age” to property listings
- Feng-shui widgets for interior design sites
- Filter apartments by door direction in a search app
- Content pages such as “born in 1990, which direction”
FAQ
Is the year the solar or the lunar year?
The lunar year. Send birth_date to have it computed, or year if you already know the lunar year.
Which school is used?
Bát trạch with the usual cung phi formula; other schools may differ for some years.
What is the house direction?
The direction the main door faces, measured from inside the house looking out.
Related APIs
JSON Validator
Check JSON syntax with exact line and column of errors, and validate data against a JSON Schema (draft 4, 7, 2019-09 or 2020-12).
{ }JSON Formatter
Pretty print JSON with 0-8 spaces or tabs, minify it, or sort object keys recursively. Syntax errors are reported with line and column.
CSVCSV to JSON
Convert CSV into an array of JSON objects using the header row, with delimiter auto-detection, number and boolean typing, and row-level errors.