安裝 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 · or use 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 202401 --to 202612 --top 3 --pretty
快速開始 Quick start
Quick start 快速開始
指定地址、月份範圍與筆數即可取得結果。--pretty 會輸出排版過的 JSON。
Pass an address, a month range and a count to get results. --pretty prints formatted JSON.
$ tw-lvr extract --where "新竹市東區關新路" --from 202401 --to 202612 --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 202401 --to 202612 --out result.json # → result.json · 資料留在磁碟,不進 context · data stays on disk, out of context
指令與參數 Commands & flags
Commands & flags 指令與參數
主要指令是 extract,完整簽章如下:
The main command is extract. Full signature:
tw-lvr extract --where <地址> --from <YYYYMM> --to <YYYYMM> [--refine] [--ptype 1,2] [--query biz|sale|rent | --presale | --rent] [--top N | --limit N] [--community <社區名>] [--out <檔案|資料夾>] [--format json|csv] [--pretty]
參數說明
Flag reference
| Flag | 說明 | Description |
|---|---|---|
| --where <地址> | 查詢地址(必填) | Address to query (required) |
| --from / --to | 月份範圍(YYYYMM) | Month range (YYYYMM) |
| --refine | 加上調整後單價、排除旗標與 confidence | Adds adjusted unit price, exclusion flags & confidence |
| --ptype <codes> | 依物件類型代碼篩選。買賣預設 1,2(房地);3 土地、4 建物、5 車位。租賃預設 1,2,3,4,5,6,7——6/7 為 112/09 新制的建物租賃,覆寫時至少保留一個 1–5 代碼 | Filter by property-type codes. Sale default 1,2 (house+land); 3 land, 4 building, 5 parking. Rent default 1,2,3,4,5,6,7 — 6/7 carry post-2023-09 new-form building leases; keep at least one 1–5 code when overriding |
| --query biz|sale|rent | 查詢類別,預設 biz(成屋買賣);sale 預售屋;rent 租賃 | Query category, default biz (completed-home sales); sale = presale; rent = rental |
| --presale | 改查預售屋 | Switch to presale units |
| --rent | 改查租賃(租賃結構;路名在本地過濾;日期區間拉寬並看 coverage 逐年筆數) | Switch to rental (lease schema; road filtered client-side; widen dates & check the coverage line) |
| --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 # 列出完整欄位與詞彙表 · full field glossary $ tw-lvr --help # 指令說明 · command help $ tw-lvr --version # 版本 · version
預設為 --query biz(成屋買賣);--presale 會切換到預售屋;--rent 切換到租賃(輸出為租賃結構,欄位見 tw-lvr glossary --rent;租賃資料逐年連續、更新到當月,先看 stderr 的 coverage: 逐年筆數再談趨勢)。資料量大或月份跨度長時,請切成每段 60 個月以內 分批查詢,否則過大的回應會以 ERR_NETWORK 失敗。
Default is --query biz (completed-home sales); --presale switches to presale units; --rent switches to rental (lease output schema — see tw-lvr glossary --rent; rental coverage is continuous and current — check the per-year coverage: stderr line before trending). For large or long ranges, split into chunks of 60 months 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.
--rent 回傳獨立的租賃結構,不是買賣欄位:monthlyRentTwd(月租金,元非萬)、unitRentTwdPing(元/坪/月)、rentTarget(租賃標的)、hasMgmtOrg/hasFurniture(管理組織/附傢俱)、rentPeriod(租期);2023-09 新版申報書之後的案件另有 rentalType(出租型態)、rentalService(租賃住宅服務——社會住宅* 為補貼案件,做市場行情請先剔除)、hasElevator、equipment。完整欄位:tw-lvr glossary --rent。租賃資料逐年連續、更新到當月;先看 stderr 的 coverage: 逐年筆數再談趨勢(跨 2023-09 的變化含申報主體改變的成分)。查詢帶路名時由 CLI 在本地過濾到該路段(政府網站的租賃查詢只到行政區層級,stderr 會註明筆數)。
--rent returns a separate lease schema, not the sale fields: monthlyRentTwd (monthly rent, in TWD not 萬), unitRentTwdPing (TWD/ping/month), rentTarget, hasMgmtOrg/hasFurniture, rentPeriod; leases signed after the Sep-2023 reporting-form change also carry rentalType, rentalService (社會住宅* values are subsidized social housing — drop for market-rate comps), hasElevator, equipment. Full dictionary: tw-lvr glossary --rent. Rental coverage is continuous and current; check the per-year coverage: stderr line before reading trends (shifts across Sep 2023 are partly compositional — the reporter mix changed). A road in --where is filtered client-side for rent (the government site only resolves rentals to district level; stderr notes the counts).
結束代碼 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: '202401', to: '202612', }); const records: CleanRawRecord[] = res.data ?? []; // extract returns Result; records live in res.data/extract 回傳 Result;資料在 res.data console.log(records[0]?.totalPriceWan); // Use extractRefined() for adjusted prices and flags/需要調整後單價與旗標時,改用 extractRefined()
首次查詢會啟動一個可重用的 headless 瀏覽器;閒置 15 秒後自動關閉,腳本會自行結束(LVR_BROWSER_IDLE_MS 可調)。要立即結束、或在常駐程式中自行控制關閉時機,呼叫 closeBrowser()。
The first query launches one reusable headless browser; it closes itself after 15 seconds idle, so plain scripts exit on their own (tune with LVR_BROWSER_IDLE_MS). For immediate exit, or to own the shutdown in long-lived processes, call closeBrowser().
當 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–3 秒。
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 2–3s 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, convertible to 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 | 分段查詢(每次 60 個月以內) | Split into chunks of 60 months or less |
| 被限流 | Rate limited | exit 5 → 稍後再試 | exit 5 → try again later |
| 網站改版 | Source site changed | exit 3 → 回報 issue | exit 3 → file an issue |