安裝 Install
Install 安裝
用 npm 或 bun 全域安裝。安裝後另需執行一次 Playwright 的 headless Chromium 下載——這是唯一的非 JavaScript 相依套件。
Install globally with npm or bun. After installing, run Playwright's headless Chromium download once — this is the only non-JavaScript dependency.
$ npm i -g tw-lvr-cli # 或使用 bun $ bun add -g tw-lvr-cli
$ npx playwright install chromium-headless-shell
若缺少 headless Chromium,CLI 會以結束代碼 6(ERR_ENV)退出,並印出上面的安裝指令。
If headless Chromium is missing, the CLI exits with code 6 (ERR_ENV) and prints the install command above.
不想全域安裝?單次執行
No global install? One-off run
$ npx -y tw-lvr-cli@latest extract --where "新竹市東區關新路" --from 2024 --to 2026 --top 3 --pretty
快速開始 Quick start
Quick start 快速開始
指定地址、年份範圍與筆數即可取得結果。--pretty 會輸出排版過的 JSON。
Pass an address, a year range and a count to get results. --pretty prints formatted JSON.
$ tw-lvr extract --where "新竹市東區關新路" --from 2024 --to 2026 --top 3 --pretty
最新一筆交易永遠排在最前面。加上 --out result.json 會把資料寫到磁碟——資料因此不會進入模型的 context。
The latest record is always sorted first. Adding --out result.json writes the data to disk — so it never enters the model context.
$ tw-lvr extract --where "新竹市東區關新路" --from 2024 --to 2026 --out result.json # → result.json · 資料留在磁碟,不進 context
指令與參數 Commands & flags
Commands & flags 指令與參數
主要指令是 extract,完整簽章如下:
The main command is extract. Full signature:
tw-lvr extract --where <地址> --from <YYYY> --to <YYYY> [--refine] [--ptype 1,2] [--query biz|sale | --presale] [--top N | --limit N] [--community <社區名>] [--out <檔案|資料夾>] [--format json|csv] [--pretty]
參數說明
Flag reference
| Flag | 說明 | Description |
|---|---|---|
| --where <地址> | 查詢地址(必填) | Address to query (required) |
| --from / --to | 年份範圍(YYYY) | Year range (YYYY) |
| --refine | 加上調整後單價、排除旗標與 confidence | Adds adjusted unit price, exclusion flags & confidence |
| --ptype 1,2 | 依物件類型代碼篩選 | Filter by property-type codes |
| --query biz|sale | 查詢類別,預設 biz(成屋買賣) | Query category, default biz (completed-home sales) |
| --presale | 改查預售屋 | Switch to presale units |
| --top N | --limit N | 限制回傳筆數 | Cap the number of records returned |
| --community <社區名> | 依社區名稱篩選 | Filter by community name |
| --out <檔案|資料夾> | 寫入磁碟(檔案或資料夾) | Write to disk (file or folder) |
| --format json|csv | 輸出格式,預設 json | Output format, default json |
| --pretty | 輸出排版過的 JSON | Pretty-print the JSON |
其他指令
Other commands
$ tw-lvr glossary # 列出完整欄位與詞彙表 $ tw-lvr --help # 指令說明 $ tw-lvr --version # 版本
預設為 --query biz(成屋買賣);--presale 會切換到預售屋。資料量大或年份跨度長時,請切成每段 5 年以內 分批查詢,否則過大的回應會以 ERR_NETWORK 失敗。
Default is --query biz (completed-home sales); --presale switches to presale units. For large or long ranges, split into chunks of 5 years or less — an oversized response fails with ERR_NETWORK.
輸出欄位 Output fields
Output fields 輸出欄位
每筆交易的核心欄位如下。完整欄位清單請執行 tw-lvr glossary。
Core fields per transaction below. For the full list, run tw-lvr glossary.
| Field | 欄位 | Meaning | |
|---|---|---|---|
| building | 建物 | 建物名稱 | Building name |
| address | 地址 | 地址 | Address |
| txnDateRoc | 交易日期 | 交易日期(民國) | Transaction date (ROC calendar) |
| totalPriceWan | 總價 | 總價(萬元) | Total price (10k TWD / 萬元) |
| siteAdjUnitPrice | 調整後單價 | 調整後單價 | Adjusted unit price |
| totalAreaPing | 坪數 | 總坪數 | Total area (ping / 坪) |
| layout | 格局 | 房廳衛格局 | Room layout |
--refine 會額外加上排除旗標(親友/純車位/非住宅)與每筆的 confidence。confidence 是資料品質旗標,不是估價。
--refine adds exclusion flags (related-party / parking-only / non-residential) and a per-record confidence. Confidence is a data-quality flag, not a valuation.
結束代碼 Exit codes
Exit codes 結束代碼
指令以下列結束代碼退出,方便在腳本與 CI 中判斷。
The command exits with these codes, for branching in scripts and CI.
| Code | 意義 | Meaning |
|---|---|---|
| 0 | 成功或無資料 | Success, or no data |
| 2 | 輸入錯誤 | Invalid input |
| 3 | 網站改版 | Source site changed |
| 4 | 網路 | Network error |
| 5 | 被限流 | Rate limited |
| 6 | 環境或瀏覽器 | Environment / browser |
| 7 | 部分成功 | Partial success |
架構 Architecture
Architecture 架構
每次查詢經過四個階段。
Each query passes through four stages.
--refine 時)加上調整後單價、排除旗標與 confidence。--refine) add adjusted unit price, exclusion flags and confidence.Library API 當函式庫使用
Library API use as a library
同一個引擎可以直接 import。匯出 extract 與 extractRefined,型別定義在 src/index.ts。
The same engine is importable. It exports extract and extractRefined; types live in src/index.ts.
import { extract, extractRefined } from 'tw-lvr-cli'; import type { CleanRawRecord } from 'tw-lvr-cli'; const res = await extract({ where: '新竹市東區關新路', from: '2024', to: '2026', }); const records: CleanRawRecord[] = res.data ?? []; // extract 回傳 Result;資料在 res.data console.log(records[0]?.totalPriceWan); // 需要調整後單價與旗標時,改用 extractRefined()
當 plugin 用 Use as a plugin
Use as a plugin 當 plugin 用
可安裝進 Claude Code 與 Codex,讓 agent 直接呼叫 CLI。
Install into Claude Code and Codex so an agent can call the CLI directly.
/plugin marketplace add felixfu824/taiwan-property-price-cli /plugin install tw-lvr-cli@tw-lvr-cli
$ codex plugin marketplace add felixfu824/taiwan-property-price-cli $ codex plugin add tw-lvr-cli@tw-lvr-cli
plugin 內含一份 Agent Skill(SKILL.md),告訴 agent 何時以及如何呼叫這個 CLI。
The plugin bundles an Agent Skill (SKILL.md) that tells the agent when and how to call the CLI.
給 AI agent For AI agents
For AI agents 給 AI agent
agent 應該把 tw-lvr 當成 shell 指令執行,並從 --out 指定的檔案讀取 JSON/CSV,而不是把資料讀進 context。結果是確定性的,每次查詢約 2 秒。
An agent should run tw-lvr as a shell command and read the JSON/CSV from the --out file, instead of pulling it into context. Results are deterministic, about 2s per query.
本站也提供機器可讀的參考檔:/llms.txt 與 /facts。
The site also serves machine-readable references: /llms.txt and /facts.
資料與授權 Data & license
Data & license 資料與授權
資料來源為內政部不動產實價登錄開放資料,採政府資料開放授權條款(OGDL,可轉 CC BY 4.0),須標示來源為內政部,資料依法去識別化。程式碼以 Apache-2.0 授權。
Data comes from the MOI real-price registry open data under the Open Government Data License (OGDL, compatible with CC BY 4.0); the source must be attributed to MOI and the data is de-identified by law. The code is licensed Apache-2.0.
隱私
Privacy
- 本機執行,無 telemetry,不蒐集個資。
- Runs locally, no telemetry, collects no personal data.
- 僅寫入
--out指定的路徑。 - Writes only to the path given in
--out. - 對外請求僅限
lvr.land.moi.gov.tw。 - Outbound requests are limited to
lvr.land.moi.gov.tw.
本工具與內政部無任何關係,按現狀(as-is)提供。
This tool is unaffiliated with MOI and is provided as-is.
疑難排解 Troubleshooting
Troubleshooting 疑難排解
| 症狀 | Symptom | 處理 | Fix |
|---|---|---|---|
| chrome-headless-shell 未安裝 | chrome-headless-shell not installed | exit 6 → 執行安裝指令 npx playwright install chromium-headless-shell |
exit 6 → run npx playwright install chromium-headless-shell |
| 回應過大 | Response too large | 分段查詢(每次 5 年以內) | Split into chunks of 5 years or less |
| 被限流 | Rate limited | exit 5 → 稍後再試 | exit 5 → try again later |
| 網站改版 | Source site changed | exit 3 → 回報 issue | exit 3 → file an issue |