|

← トップへ戻る

開発者向け — API・MCP・機械可読データ

本サービスの比較結果は、人間向けのレポート HTML だけでなく、 プログラムや AI エージェントから使える機械可読データとしても 提供しています。すべて認証不要・読み取り自由です (出典: 各フィードのライセンスに従います。利用規約)。

1. 提供している層

層中身向く用途
digest比較の要約 (Markdown / JSON)。路線ごとの変化・停留所の変化・被覆率LLM に渡す一次資料、告知文づくり、突合
routes.digest.json全路線の詳細 — 変化した便のレコード (trip_id 旧新付き)・時間帯別本数路線の深掘り
mapping.jsonstop_id / route_id / trip_id の旧新対応表 (N:M は配列のまま、confidence 付き)乗降データの経年結合、shapes 等の整備資産の世代引き継ぎ
events.json / rawdiffs.json全 ChangeEvent (44種) +証拠、生差分の全件エラーチェック、完全な検証

本ツールの特徴は「説明台帳」: 2世代間の生差分の全件が、必ず いずれかのイベントの証拠に紐づくか残差として計上され、被覆率 (explained_ratio) が常に出ます。検出は決定的ルールベースで、同じ入力からは 常に同じ出力になります。

2. URL の規則 (最短の入口)

レポート URL の .html を .digest.md に変えるだけで、 機械可読の要約が取れます:

https://diff.gtfs.jp/r/{pair}.html        ← 人間向けレポート
https://diff.gtfs.jp/r/{pair}.digest.md   ← AI 向け要約 (Markdown)
https://diff.gtfs.jp/r/{pair}.mapping.json ← ID 対応表 (gzip)
https://diff.gtfs.jp/r/{pair}/index.json  ← 版台帳 (全成果物の URL 一覧)

URL 規則を覚える必要はありません — 版台帳 (index.json) の versions[].artifacts に全成果物の URL が列挙されます。 フィード単位の計算済みペア一覧は https://diff.gtfs.jp/feeds/{org}__{feed}.json にあります。

3. MCP サーバー (AI エージェント向け)

https://diff.gtfs.jp/mcp

Claude・ChatGPT 等の AI にコネクタとして登録すると、上記のデータを ツールとして対話的に使えます。認証不要 (Bearer トークン・ カスタムヘッダー等はすべて空欄のままで接続できます)。

ツール説明
find_feeds / find_generationsフィード・世代の探索 (gtfs-data.jp)
list_pairs計算済みの比較ペア一覧
run_compare / get_job_status未計算の世代ペアをその場で計算 (日次の回数ガードあり)
get_digest / list_routes / get_route_detail要約と路線詳細
get_stop_changes / get_residuals停留所の変化・検証サマリ (説明台帳)
map_idsstop_id / route_id / trip_id / 名前から新旧対応を検索
get_eventsChangeEvent の検索 (種別・重要度・路線で絞り込み)

プロトコルは MCP 2026-07-28 版と旧世代 (initialize 方式) の 両対応。レポート URL の r/{pair}.html の {pair} 部分が そのままツールの pair 引数になります。

4. 比較の実行 (Web API)

# 世代一覧 (uid の確認)
curl "https://diff.gtfs.jp/api/gtfs/files?org=nagai-unyu&feed=Nagaibus"

# 比較ジョブの投入 (uid でも rid = prev_1/current 等でも可)
curl -X POST https://diff.gtfs.jp/api/jobs \
  -H "Content-Type: application/json" \
  -d '{"type":"gtfs_data_jp","org":"nagai-unyu","feed":"Nagaibus",
       "old_rid":"prev_1","new_rid":"current"}'
# → {"job_id":"{pair}", ...}。GET /api/jobs/{pair} で succeeded を待つ

計算済みの世代ペアは即座に返ります (同一ペアは誰が実行しても 同じ公開 URL)。新規計算には日次の回数上限があり、超過時は 429 が返ります。 大量の処理は CLI をローカルでどうぞ (下記ドキュメント参照)。

処理規模の上限: アップロードは zip 100MB/ファイルに加え、 stop_times.txt の非圧縮サイズが約 100MB/世代 (≈130万便区間) を超えるものは 投入時にお断りします (国家規模の統合フィード等)。それ以上の規模は オープンソースの CLI 版で — 同じレポートを上限なしでローカル生成できます。

5. ドキュメント

ページ内容
/docs/README.ja.md案内 — 何ができるか、層の選び方、ユースケース別レシピ (英語版: README.md)
/docs/reference.ja.mdリファレンス — CLI / Web API / JSON スキーマ / イベント型カタログ全44種 / digest・mapping スキーマ (英語版: reference.md)
/llms.txtAI エージェント向けの機械可読な案内

6. 利用にあたって

本機能は研究プロジェクトの一部として提供しています。 不具合・要望はトップページのフィードバックからお寄せください。

← Back to top

For developers — API, MCP and machine-readable data

Comparison results are available not only as human-readable HTML reports but also as machine-readable data for programs and AI agents. Everything is read-free with no authentication (attribution follows each feed's license — see the terms).

1. Available layers

LayerContentsGood for
digestComparison summary (Markdown / JSON): per-route changes, stop changes, coveragePrimary source for LLMs, drafting notices, cross-checking
routes.digest.jsonDetail for every route — changed-trip records (old/new trip_ids), counts by time bandDrilling into a route
mapping.jsonOld↔new correspondence tables for stop_id / route_id / trip_id (N:M kept as arrays, with confidence)Joining ridership data across versions, carrying assets like shapes forward
events.json / rawdiffs.jsonAll ChangeEvents (44 types) with evidence, plus every raw diffError checking, full verification

The tool's distinguishing feature is the "explanation ledger": every raw difference between the two versions is either tied to an event as evidence or reported as a residual, and the coverage ratio (explained_ratio) is always published. Detection is deterministic and rule-based — the same input always yields the same output.

2. URL scheme (the shortest entry point)

Change .html to .digest.md in any report URL to get the machine-readable summary:

https://diff.gtfs.jp/r/{pair}.html        ← human-readable report
https://diff.gtfs.jp/r/{pair}.digest.md   ← summary for AI (Markdown)
https://diff.gtfs.jp/r/{pair}.mapping.json ← ID mapping (gzip)
https://diff.gtfs.jp/r/{pair}/index.json  ← version ledger (URLs of all artifacts)

You do not need to memorize the URL rules — the version ledger (index.json) lists every artifact URL under versions[].artifacts. The list of computed pairs per feed is at https://diff.gtfs.jp/feeds/{org}__{feed}.json.

3. MCP server (for AI agents)

https://diff.gtfs.jp/mcp

Register it as a connector in Claude, ChatGPT or another AI client and the data above becomes interactive tools. No authentication (leave bearer tokens and custom headers empty).

ToolDescription
find_feeds / find_generationsExplore feeds and versions (gtfs-data.jp)
list_pairsList already-computed comparison pairs
run_compare / get_job_statusCompute a new pair on the spot (daily rate guard applies)
get_digest / list_routes / get_route_detailSummary and per-route detail
get_stop_changes / get_residualsStop changes and the verification summary (explanation ledger)
map_idsLook up old↔new correspondences by stop_id / route_id / trip_id / name
get_eventsSearch ChangeEvents (filter by type, severity, route)

The server speaks both the 2026-07-28 MCP protocol and the older initialize-style generation. The {pair} part of a report URL (r/{pair}.html) is exactly the pair argument of the tools.

4. Running a comparison (Web API)

# List versions (to find uids)
curl "https://diff.gtfs.jp/api/gtfs/files?org=nagai-unyu&feed=Nagaibus"

# Submit a comparison job (uid or rid = prev_1 / current both work)
curl -X POST https://diff.gtfs.jp/api/jobs \
  -H "Content-Type: application/json" \
  -d '{"type":"gtfs_data_jp","org":"nagai-unyu","feed":"Nagaibus",
       "old_rid":"prev_1","new_rid":"current"}'
# → {"job_id":"{pair}", ...}; poll GET /api/jobs/{pair} until succeeded

Already-computed pairs return immediately (the same pair gets the same public URL no matter who runs it). New computations are subject to a daily limit; when exceeded, the API returns 429. For bulk processing, run the CLI locally (see the documentation below).

Size limits: uploads are capped at 100MB per zip, and feeds whose uncompressed stop_times.txt exceeds ~100MB per version (≈1.3M rows — national aggregate feeds and the like) are declined at submission. For larger feeds use the open-source CLI — it produces the same report locally with no limits.

5. Documentation

PageContents
/docs/README.mdGuide — what you can do, choosing a layer, recipes by use case (Japanese: README.ja.md)
/docs/reference.mdReference — CLI / Web API / JSON schemas / all 44 event types / digest & mapping schemas (Japanese: reference.ja.md)
/llms.txtMachine-readable guidance for AI agents

6. Ground rules

This is provided as part of a research project. Please send bugs and requests via the feedback form on the top page.