Feng Shui API
Chinese astrology and feng shui as a REST API and free online calculators: zodiac signs and Four Pillars, compatibility, Kua numbers, Eight Mansions, Flying Star charts and Lu Ban lucky dimensions for any date from 1700 to 2300.
Popular calculators
Kua number
Your lucky and unlucky directions.
Chinese zodiac sign
Your animal, element and year pillar.
Love compatibility
How well two birth years match.
Flying Star chart
The natal chart of any building.
Eight Mansions
Good and bad sectors of a home.
Lucky dimensions
Check sizes on the Lu Ban ruler.
For developers
Paste your API key and call any endpoint. Requests go to /api/v2 with the X-API-Key header. No key yet? Create a free account — or use the calculators, which need none.
Reference
The complete, machine-readable contract is the OpenAPI 3.1 specification (JSON), browsable in the interactive docs. The essentials:
Base URL & authentication
All endpoints live under https://fengshui-api.com/api/v2, accept GET query parameters and return JSON. Send your key in the X-API-Key header, or as Authorization: Bearer <key>. Keys never go in the URL.
curl -H "X-API-Key: $FENGSHUI_API_KEY" \ "https://fengshui-api.com/api/v2/zodiac/year?date=1990-06-15"
Endpoints
| Endpoint | Parameters | Returns |
|---|---|---|
/zodiac/year | date, calendar | Year animal, element, pillar, start/end |
/zodiac/month | date, calendar | Month animal, pillar; lunar number/leap or solar term |
/zodiac/day | date | Day animal and pillar |
/zodiac/hour | time (HH:MM) | Hour animal and its two-hour range |
/zodiac/allies, /enemy, /secret-friend, /peach-blossom | date or animal, calendar | Related animals (and Peach Blossom direction) |
/compatibility/love, /compatibility/business | date1|animal1, date2|animal2 | Score 1–4 and rating |
/feng-shui/kua | date, gender (male|female), calendar | Kua, group, trigram, 8 directions |
/feng-shui/eight-mansions | facing (degrees or N…NW) | House trigram and sector stars |
/feng-shui/flying-star | facing (degrees, N1…NW3 or name), period or constructionYear | Nine-palace chart and chart type |
/feng-shui/lucky-dimension | length, unit (mm|cm|in) | Lu Ban section and alternatives |
/me | — | Your account and remaining quota (DELETE removes the account) |
Dates and calendars
Dates use ISO 8601 (YYYY-MM-DD) and must fall between 1700-01-01 and 2300-12-31. With calendar=lunar (default) years begin at the lunar new year and months at new moons. With calendar=solar years begin at Li Chun (about 4 February) and months at the twelve "jie" solar terms — the Four Pillars convention. The calendar is computed for China Standard Time (UTC+8).
Errors
Errors follow RFC 9457 (application/problem+json) with the proper HTTP status: 401 missing or invalid key, 404 unknown endpoint, 422 invalid parameters (each listed in errors), 429 quota exceeded.
{
"type": "about:blank",
"title": "Unprocessable Content",
"status": 422,
"detail": "One or more parameters are invalid.",
"errors": [{ "parameter": "date", "message": "Must be between 1700-01-01 and 2300-12-31." }]
}
Rate limits
Each key may make 1000 requests per hour. Every response carries the IETF RateLimit-Policy and RateLimit headers (e.g. "hourly";r=998;t=0 — remaining requests and seconds until more are available). When the quota is used up the API answers 429 with Retry-After.
Code examples
# Create an account (or use the sign-up page); the key is shown once curl -X POST https://fengshui-api.com/api/v2/accounts \ -H "Content-Type: application/json" \ -d '{"name":"Jane","email":"[email protected]","password":"a long passphrase","useCase":"Feng shui app"}' # Kua number and personal directions curl -H "X-API-Key: $FENGSHUI_API_KEY" \ "https://fengshui-api.com/api/v2/feng-shui/kua?date=1985-03-15&gender=female" # Flying Star chart, period 9, facing 180° curl -H "X-API-Key: $FENGSHUI_API_KEY" \ "https://fengshui-api.com/api/v2/feng-shui/flying-star?facing=180&period=9"
import os
import requests
session = requests.Session()
session.headers["X-API-Key"] = os.environ["FENGSHUI_API_KEY"]
BASE = "https://fengshui-api.com/api/v2"
year = session.get(f"{BASE}/zodiac/year", params={"date": "1990-06-15"}).json()
print(year["animal"], year["pillar"]["name"]) # Horse Geng Wu
kua = session.get(f"{BASE}/feng-shui/kua", params={"date": "1985-03-15", "gender": "female"})
kua.raise_for_status()
for d in kua.json()["favorableDirections"]:
print(d["direction"], d["star"])
const BASE = "https://fengshui-api.com/api/v2";
async function fengShui(path, params) {
const response = await fetch(`${BASE}${path}?${new URLSearchParams(params)}`, {
headers: { "X-API-Key": process.env.FENGSHUI_API_KEY },
});
if (!response.ok) throw new Error((await response.json()).detail);
return response.json();
}
const match = await fengShui("/compatibility/love", { date1: "1990-06-15", date2: "1992-03-10" });
console.log(match.score, match.rating);
<?php
$context = stream_context_create(['http' => [
'header' => 'X-API-Key: ' . getenv('FENGSHUI_API_KEY'),
'ignore_errors' => true,
]]);
$query = http_build_query(['length' => 85, 'unit' => 'cm']);
$result = json_decode(file_get_contents("https://fengshui-api.com/api/v2/feng-shui/lucky-dimension?$query", false, $context), true);
echo $result['auspicious'] ? 'Lucky' : 'Unlucky', ': ', $result['section']['meaning'];
Flying Star periods
| Period | Years | Period | Years | Period | Years |
|---|---|---|---|---|---|
1 | 1864–1883 | 4 | 1924–1943 | 7 | 1984–2003 |
2 | 1884–1903 | 5 | 1944–1963 | 8 | 2004–2023 |
3 | 1904–1923 | 6 | 1964–1983 | 9 | 2024–2043 |
The cycle repeats every 180 years (period 1 again from 2044). Pass constructionYear to let the API choose the period.
The 24 mountains
| Code | Name | Degrees | Code | Name | Degrees | Code | Name | Degrees |
|---|---|---|---|---|---|---|---|---|
N1 | Ren 壬 | 337.5–352.5 | E1 | Jia 甲 | 67.5–82.5 | S1 | Bing 丙 | 157.5–172.5 |
N2 | Zi 子 | 352.5–7.5 | E2 | Mao 卯 | 82.5–97.5 | S2 | Wu 午 | 172.5–187.5 |
N3 | Gui 癸 | 7.5–22.5 | E3 | Yi 乙 | 97.5–112.5 | S3 | Ding 丁 | 187.5–202.5 |
NE1 | Chou 丑 | 22.5–37.5 | SE1 | Chen 辰 | 112.5–127.5 | SW1 | Wei 未 | 202.5–217.5 |
NE2 | Gen 艮 | 37.5–52.5 | SE2 | Xun 巽 | 127.5–142.5 | SW2 | Kun 坤 | 217.5–232.5 |
NE3 | Yin 寅 | 52.5–67.5 | SE3 | Si 巳 | 142.5–157.5 | SW3 | Shen 申 | 232.5–247.5 |
W1 | Geng 庚 | 247.5–262.5 | NW1 | Xu 戌 | 292.5–307.5 | |||
W2 | You 酉 | 262.5–277.5 | NW2 | Qian 乾 | 307.5–322.5 | |||
W3 | Xin 辛 | 277.5–292.5 | NW3 | Hai 亥 | 322.5–337.5 |
Measure the facing with a compass standing inside the main entrance and looking out.
Frequently asked questions
Is the API free? Yes — an account gives you a key instantly, with 1000 requests per hour.
Which dates are supported? Every date from 1 January 1700 to 31 December 2300.
How is the Kua number calculated? From the Chinese year and gender following the nine-year Luo Shu cycle: male (11 − year mod 9) mod 9, female (year mod 9 + 4) mod 9, 0 read as 9; a 5 becomes 2 for men and 8 for women.
Lunar or solar calendar? Both — lunar by default, calendar=solar for the Four Pillars convention.
Changelog
| Version | Changes |
|---|---|
2.0.0 | New /api/v2: API key in a header, RFC 9457 errors, IETF rate-limit headers, OpenAPI 3.1 and interactive docs. Calendar data for 1700–2300 with leap months and solar terms; lunar and solar (Ba Zi) calendars; stem–branch pillars. Flying Star for all periods 1–9 and all 24 mountains; corrected Eight Mansions, Kua (births from 2000 on), compatibility tables and Lu Ban ruler. Free web calculators, an account dashboard with e-mail confirmation, password reset and account deletion. API v1 retired. |
1.x | Original API with query-string keys (retired). |