API Reference
APIリファレンス
公金データを、出典付きで参照するための公開 API の完全リファレンスです。 認証・レート制限・出典フィールド・エラー・全エンドポイントをまとめています。 仕様の機械可読な正本は Swagger UI(/docs)と openapi.json、 手を動かす例は 実例ガイドにあります。
基本
- ベース URL:
https://national-os.jp(全エンドポイントは/api/v1/…)。 - 形式: すべて JSON。GET が中心で、キー申請と MCP のみ POST です。
- 認証: 公開エンドポイントはキーなしでも利用できます。 APIキーはレート上限を引き上げるためのもので、
X-API-Keyヘッダーに付けます。 MCP(/api/v1/mcp)のみキーが必須です。 - 出典: リクエストに
X-Data-Format: v2を付けると、対応するエンドポイントの応答にprovenance(出典)が加わります(下記)。
レート制限
| 区分 | 通常(回/分) | 重い集計(回/分) | 上限(回/日) |
|---|---|---|---|
| キーなし(匿名) | 60 | 10 | 5,000 |
| 一般(無料枠) | 600 | 30 | 50,000 |
| 研究・報道 | 1,200 | 120 | 上限なし |
「重い集計」は検索・ランキング・突合など負荷の大きい一部エンドポイントの別枠です (下の一覧で「重い集計」と記したもの)。超過すると 429 が返り、 Retry-After に再試行までの秒数が入ります。 研究・報道枠は /api-access から申請できます。
出典(provenance)フィールド
X-Data-Format: v2 を付けたとき、対応する エンドポイントの応答に provenance が加わります。 enum・ハッシュ・URL・日時・原典ラベルだけで構成し、自由文の評価は含めません。 行が無い項目は捏造せず null を返します。
| フィールド | 意味 |
|---|---|
| source_url | 原典の URL。数値の最終根拠となる一次資料。 |
| source_type | 原典の種別(excel / api_json / pdf / htmlscrape / csv / direct_input)。 |
| source_hash | 原典ファイルの sha256(64 桁)。取得時点の原本と照合できます。 |
| data_hash | 正規化後データの sha256。 |
| confirmed_at | 当方が原典を取得・観測した日時。 |
| published_at | 原典が公表された日時(判明する場合)。 |
| data_status | confirmed / provisional / under_review / unavailable の 4 値。 |
| confidence | confirmed / probable / estimated / missing の 4 値。 |
| human_review_required | 人手レビュー待ちか(true / false)。 |
| original_label | 原典の生ラベル。 |
| normalized_label | 正規化後のラベル。 |
エラー
| ステータス | 返るとき |
|---|---|
| 400 | パラメータが不正なとき。 |
| 401 | APIキーが無効・失効しているとき(キーを外せば匿名で叩けます。MCP はキー必須)。 |
| 404 | 対象が存在しないとき。 |
| 409 | 競合(同一メールの申請が既にある等)。 |
| 429 | レート超過。Retry-After(秒)と X-RateLimit-Limit / -Remaining ヘッダーが付きます。 |
エンドポイント一覧
公開エンドポイントをカテゴリ別に掲載します(内部・運用向けは除く)。各エンドポイントの リクエスト/レスポンスの詳細スキーマは /docs が正本です。
システム・メタ
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/health | ヘルスチェック(レート制限の対象外) | — |
| GET | /api/v1/about | サイト・データのメタ情報 | — |
マスタ(都道府県・自治体)
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/prefectures | 都道府県の一覧 | — |
| GET | /api/v1/municipalities | 自治体の一覧・検索 | pref, type, q, exclude_wards, limit, offset |
| GET | /api/v1/municipalities/{jis_code} | 自治体の詳細 | — |
| GET | /api/v1/municipalities-summary | 自治体の集計サマリ | — |
| GET | /api/v1/geo/prefectures/{pref_code} | 都道府県の境界 GeoJSON | — |
| GET | /api/v1/geo/muni/{pref_code}.geojson | 市区町村の境界 GeoJSON | — |
自治体プロフィール(人口・財政・税)
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/profile/{jis_code} | 人口+財政の統合プロフィール | — |
| GET | /api/v1/fiscal/ranking | 財政ランキング | year, sort, order, limit |
| GET | /api/v1/fiscal/{jis_code} | 自治体の財政サマリ(全年度) | — |
| GET | /api/v1/fiscal/{jis_code}/{year} | 自治体の単年度財政 | — |
| GET | /api/v1/population/{jis_code} | 人口の推移 | — |
| GET | /api/v1/tax-receipt/{jis_code} | 税収 | — |
| GET | /api/v1/municipal-tax/{jis_code} | 市町村税の内訳 | year, table_code |
自治体の財政詳細・社会指標
地方債・基金・歳入内訳・住民負担・地価・介護・上下水道・国保・防災・労働・教育・医療・福祉・経済・住宅など。多くは /{jis_code} と /{jis_code}/trend を持ちます。
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/local-bonds/{jis_code} | 地方債(+ /trend) | year |
| GET | /api/v1/reserve-funds/{jis_code} | 基金 | year |
| GET | /api/v1/revenue-detail/{jis_code} | 歳入の内訳 | year |
| GET | /api/v1/burden/{jis_code} | 住民負担(+ /ranking/{metric}) | year |
| GET | /api/v1/land-price/{jis_code} | 地価(+ /trend, /ranking/expensive) | year, land_type |
| GET | /api/v1/ltc/{jis_code} | 介護保険(+ /trend) | year |
| GET | /api/v1/water/{jis_code} | 上下水道 | — |
| GET | /api/v1/insurance/{jis_code} | 国民健康保険 | — |
| GET | /api/v1/safety/{jis_code} | 防災・安全 | — |
| GET | /api/v1/labor/{jis_code} | 労働 | — |
| GET | /api/v1/social-indicators/{jis_code} | 社会指標(+ /trend, /available/indicators) | year, indicator_code |
| GET | /api/v1/education/{jis_code} | 教育統計(+ /trend) | year |
| GET | /api/v1/medical/{jis_code} | 医療統計(+ /trend) | year |
| GET | /api/v1/welfare/{jis_code} | 福祉統計 | year |
| GET | /api/v1/economy/{jis_code} | 経済統計(+ /trend) | year |
| GET | /api/v1/housing/{jis_code} | 住宅統計(+ /trend) | year |
国の予算・歳出
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/national-budget | 国家予算 | year, account_type, flow_type |
| GET | /api/v1/national-budget/trend | 予算項目のトレンド | item_name(必須), account_type, flow_type |
| GET | /api/v1/national-budget-categories | 国の予算のカテゴリ一覧 | — |
| GET | /api/v1/budget-tree | 予算ツリー | year, flow_type, view, account_type |
| GET | /api/v1/budget-tree/revenue | 歳入ツリー | year |
| GET | /api/v1/budget-tree/evidence | 予算ツリーの出典 | year(必須), flow_type |
| GET | /api/v1/budget-tree/bridge | 予算のブリッジ | year |
| GET | /api/v1/expenditure/cross_pivot | 歳出クロス集計 | fy(必須) |
| GET | /api/v1/seifukankei/outflow | 政府関係機関の資金流出(+ /summary, /coverage) | fiscal_year, kikan_name, target_type, flow_type |
| GET | /api/v1/local-allocation/{prefecture_code} | 地方交付税 | fy, variant |
| GET | /api/v1/tax_reform/measures | 租税特別措置(+ /section_totals, /summary) | — |
| GET | /api/v1/enterprise-finance/overview | 地方公営企業(+ /types, /entities, /{entity_code}) | — |
| GET | /api/v1/third-sector/summary | 第三セクター(+ /entities, /by-location, /survey-years) | — |
公金フロー追跡・フローマップ
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/trace/{jis_code} | 国→県→市の公金フロー追跡 | — |
| GET | /api/v1/prefectures-overview | 都道府県の概観(+ /prefectures-summary) | — |
| GET | /api/v1/flow/{jis_code} | 自治体の資金フロー(+ /summary/{jis_code}) | year |
| GET | /api/v1/furusato/ranking | ふるさと納税ランキング(+ /{jis_code}) | year, limit |
| GET | /api/v1/flow-map/national/{fiscal_year} | 国家フローマップ(node/edge) | stage, from_id, to_id, include_edges, limit, offset |
| GET | /api/v1/flow-map/bridges/{fiscal_year} | フローマップの橋渡し | state, include_bridges, limit |
系譜(lineage)・終端分類
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/lineage/ntier/{origin_pid} | N 階層の系譜 | fy, max_depth |
| GET | /api/v1/lineage/complete-flow | 起点からの完全フロー | origin_type, origin_id(必須), fy |
| GET | /api/v1/lineage/search重い集計 | 系譜の起点を検索 | q(必須), type(必須), fy, limit |
| GET | /api/v1/lineage_termination/by-origin-pid/{origin_pid} | 終端の 3 分類 | fy |
| GET | /api/v1/lineage_termination/summary | 終端分類のサマリ | fy |
| GET | /api/v1/lineage/tier-schema | 終端タイプの定義(+ /ntier-coverage) | — |
調達・受注法人
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/procurement/summary | 調達サマリ(+ /years, /method-ratio, /sankey) | year |
| GET | /api/v1/procurement/top-contractors | 受注上位 | year, limit |
| GET | /api/v1/procurement/contracts/by-origin-pid | PID 別の契約 | origin_pid(必須), year, limit, offset |
| GET | /api/v1/procurement/by-contractor/{corporate_number} | 法人別の受注 | year, limit, offset |
| GET | /api/v1/procurement/contractor-search重い集計 | 受注者名で検索 | q(必須), limit, offset |
| GET | /api/v1/procurement/award-search重い集計 | 契約を横断検索 | contractor_name, contract_title, ministry_code, fiscal_year, amount_min, amount_max, limit, offset |
| GET | /api/v1/procurement/ministries | 府省の一覧 | — |
| GET | /api/v1/payee-corp-ranking/top重い集計 | 歳出先法人ランキング(+ /summary, /by-corp) | limit, offset, q, order |
| GET | /api/v1/local-bid-corp-ranking/top重い集計 | 自治体入札の法人ランキング | limit, offset, q, national_only, order |
突合・整合・ギャップ・網羅性
/reconciliation 配下(gap を含む)は全て「重い集計」枠です。
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/reconciliation重い集計 | 突合(1 リクエストで多数の集計) | year |
| GET | /api/v1/reconciliation/coverage重い集計 | カバレッジ | year |
| GET | /api/v1/reconciliation/rules重い集計 | 突合ルールの一覧 | — |
| GET | /api/v1/reconciliation/violations/open重い集計 | 未解決の違反 | — |
| GET | /api/v1/reconciliation/major_expense_codes重い集計 | 主要経費コード別の集計(+ /special-account-net) | — |
| GET | /api/v1/reconciliation/gap/breakdown重い集計 | ギャップの内訳(+ /timeline, /detail) | fy(必須) |
| GET | /api/v1/gaps/unified/{fiscal_year} | 統合ギャップ(+ /disclosure-route) | — |
| GET | /api/v1/completeness/overview | 網羅性の概観(+ /tree, /items, /by_classification, /unknown_top, /row/{row_id}) | year(必須) |
比較・ランキング・スパークライン
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/national-compare | 全国比較 | year |
| GET | /api/v1/prefecture-compare/{pref_code} | 都道府県比較(+ /timeline) | year |
| GET | /api/v1/spark/{level}/{code} | スパークライン用の系列 | — |
| GET | /api/v1/ranking/unified/{metric}重い集計 | 統合ランキング(+ /unified-metrics) | — |
会計検査院
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/audit/summary | 検査サマリ(+ /years, /ministries) | — |
| GET | /api/v1/audit/findings | 指摘事項の一覧(+ /{finding_id}, /top-findings) | year, category, ministry, limit, offset |
出典・鮮度
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/data_sources | データソースの一覧(+ /{source_id}) | — |
| GET | /api/v1/evidence/{snapshot_id} | snapshot(原資料)の詳細 | — |
| GET | /api/v1/evidence/by-source/{source_id} | ソース別の evidence | year |
| GET | /api/v1/freshness | データの鮮度一覧(+ /{source_id}/runs) | — |
APIキー
キーの発行・自己管理。form-token → applications で発行、/keys/me 系はキーを付けて自己管理、/keys/manage 系は申請メール宛のリンクで管理します。
| メソッド | パス | 内容 | 主なパラメータ |
|---|---|---|---|
| GET | /api/v1/keys/form-token | 申請フォーム用の署名トークンを発行 | — |
| POST | /api/v1/keys/applications | APIキーの発行申請(一般=即時、研究・報道=審査) | — |
| GET | /api/v1/keys/me | 自キーの状態(キーを付けて呼ぶ) | — |
| POST | /api/v1/keys/me/revoke | 自キーを失効 | — |
| POST | /api/v1/keys/me/rotate | 自キーを再発行(新キーを1回だけ返す) | — |
| POST | /api/v1/keys/manage/request-link | メールで全キーの管理リンクを送る | |
| GET | /api/v1/keys/manage | 管理リンクの token で全キーを一覧 | token |
| POST | /api/v1/keys/manage/revoke | 管理リンクの token でキーを失効 | token, key_prefix |
次に
- 実例ガイド ・ curl / Python / MCP での具体的な使い方(キー取得→検索→出典の読み取り)
- /api-docs ・ やさしい入口(クイックスタート)
- /docs ・ Swagger UI(全エンドポイントの対話的な仕様)
- /api-access ・ APIキーの発行申請