{"openapi":"3.1.0","x-id-version":"v0","x-id-status":"provisional","x-source-version":"J-FlwDir v1.4","x-credit":"J-FlwDir（東京大学・京都大学。国土地理院 基盤地図情報をもとに作成）を加工して作成","x-license":"CC BY 4.0","info":{"title":"流域の参照 API（v0）","version":"v0","description":"流域 ID・流域名・位置から流域を引く読み取り専用の API。認証なし。\n\nv0 の流域 ID はデモ用です。v1 の ID の公開で /v0 ごと廃止します。v0 の ID を KUKAN の流域タグなど後に残るところに使わないでください。\n\nID の文字列から親子・水系・階層を推測しないでください。親子は parent_id・ancestors、第1階層は ancestors の先頭（自分が第1階層ならその流域）、階層の符号は pfafstetter を使います。\n\n流域は地形（J-FlwDir）から計算したものです。都市部では下水道や水路で実際の水の流れが違うことがあります。\n\n位置の判定は元の格子（約 30 m）より細かくはなりません。境界から 30 m 以内の点には near_boundary: true を付けます。\n\nすべての応答（エラーを含む）に id_version・id_status・source_version・credit・license が入る。データは CC BY 4.0。\n\n同じ機能を MCP（Streamable HTTP）で /mcp に出している。","license":{"name":"MPL-2.0 (code); data CC BY 4.0","identifier":"MPL-2.0"}},"servers":[{"url":"/v0"}],"paths":{"/meta":{"get":{"operationId":"getMeta","summary":"ID の版、データの版、クレジット、件数、注記","responses":{"200":{"description":"メタデータ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Meta"}}}}}}},"/watersheds/{id}":{"get":{"operationId":"getWatershed","summary":"1 流域の属性・祖先・子","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"流域","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Watershed"}}}},"404":{"description":"存在しない ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"欠番の ID（retired_at、分かれば successor_id）","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/watersheds/{id}/geometry":{"get":{"operationId":"getWatershedGeometry","summary":"流域のポリゴン（GeoJSON Feature）。配布中の PMTiles のタイルをつないだもの","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"simplify","in":"query","description":"単純化の許容幅（メートル）","schema":{"type":"number","minimum":0}}],"responses":{"200":{"description":"GeoJSON Feature（MultiPolygon）","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"引数の誤り","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"存在しない ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"欠番の ID","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/watersheds":{"get":{"operationId":"searchWatersheds","summary":"名前で探す（完全一致 → 前方一致 → 部分一致、同じ順位は階層の浅い順・面積の大きい順）","parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string"}},{"name":"level","in":"query","schema":{"type":"integer","minimum":1,"maximum":4}},{"name":"kind","in":"query","schema":{"$ref":"#/components/schemas/Kind"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}}],"responses":{"200":{"description":"候補","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResult"}}}},"400":{"description":"引数の誤り","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/locate":{"get":{"operationId":"locate","summary":"点を含む流域（第1階層から最も深い階層まで）","description":"海や流域の外の点では watersheds が空になり、nearest に最も近い第1階層の流域と距離が入る。境界から 30 m 以内なら near_boundary: true。","parameters":[{"name":"lat","in":"query","required":true,"schema":{"type":"number"}},{"name":"lon","in":"query","required":true,"schema":{"type":"number"}}],"responses":{"200":{"description":"位置の判定","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocateResult"}}}},"400":{"description":"引数の誤り","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/intersect":{"post":{"operationId":"intersect","summary":"GeoJSON（点・線・面）と重なる流域","description":"範囲の外接矩形が z9 で 16 タイルを超えると 413。","parameters":[{"name":"level","in":"query","required":true,"schema":{"type":"integer","minimum":1,"maximum":4}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"description":"GeoJSON Geometry・Feature・FeatureCollection"}}}},"responses":{"200":{"description":"重なる流域","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntersectResult"}}}},"400":{"description":"引数の誤り","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"範囲が広すぎる","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"Kind":{"type":"string","enum":["basin","coast_group","island"]},"Ref":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"level":{"type":"integer"}},"required":["id","name","level"]},"Summary":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"level":{"type":"integer"},"kind":{"$ref":"#/components/schemas/Kind"},"pfafstetter":{"type":["string","null"]},"parent_id":{"type":["string","null"]},"area_km2":{"type":"number"}},"required":["id","name","level","kind","pfafstetter","parent_id","area_km2"]},"Point":{"type":"object","properties":{"lon":{"type":"number"},"lat":{"type":"number"}},"required":["lon","lat"]},"Watershed":{"allOf":[{"$ref":"#/components/schemas/Summary"},{"type":"object","properties":{"ancestors":{"type":"array","items":{"$ref":"#/components/schemas/Ref"},"description":"第1階層から親まで"},"children":{"type":"array","items":{"$ref":"#/components/schemas/Summary"}},"catalog_tags":{"type":"array","items":{"type":"string"},"description":"KUKAN の extras に入れる配列（祖先と自分の ID）"},"outlet":{"$ref":"#/components/schemas/Point"},"generated_at":{"type":"string"},"id_version":{"type":"string","const":"v0"},"id_status":{"type":"string","examples":["provisional"]},"source_version":{"type":"string","examples":["J-FlwDir v1.4"]},"credit":{"type":"string"},"license":{"type":"string","examples":["CC BY 4.0"]}},"required":["ancestors","children","catalog_tags","outlet","id_version","id_status","source_version","credit","license"]}]},"SearchResult":{"type":"object","properties":{"query":{"type":"object"},"total":{"type":"integer"},"results":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/Summary"},{"type":"object","properties":{"match":{"type":"string","enum":["exact","prefix","partial"]},"ancestors":{"type":"array","items":{"$ref":"#/components/schemas/Ref"}},"outlet":{"$ref":"#/components/schemas/Point"}}}]}},"id_version":{"type":"string","const":"v0"},"id_status":{"type":"string","examples":["provisional"]},"source_version":{"type":"string","examples":["J-FlwDir v1.4"]},"credit":{"type":"string"},"license":{"type":"string","examples":["CC BY 4.0"]}},"required":["query","total","results","id_version","id_status","source_version","credit","license"]},"LocateResult":{"type":"object","properties":{"query":{"type":"object","properties":{"lat":{"type":"number"},"lon":{"type":"number"}}},"watersheds":{"type":"array","items":{"$ref":"#/components/schemas/Summary"},"description":"第1階層から順に"},"catalog_tags":{"type":"array","items":{"type":"string"}},"near_boundary":{"type":"boolean"},"boundary_distance_m":{"type":["number","null"]},"nearest":{"oneOf":[{"type":"null"},{"type":"object","properties":{"watershed":{"$ref":"#/components/schemas/Summary"},"distance_m":{"type":"number"}}}]},"id_version":{"type":"string","const":"v0"},"id_status":{"type":"string","examples":["provisional"]},"source_version":{"type":"string","examples":["J-FlwDir v1.4"]},"credit":{"type":"string"},"license":{"type":"string","examples":["CC BY 4.0"]}},"required":["query","watersheds","catalog_tags","near_boundary","nearest","id_version","id_status","source_version","credit","license"]},"IntersectResult":{"type":"object","properties":{"level":{"type":"integer"},"bbox":{"type":"array","items":{"type":"number"}},"zoom":{"type":"integer"},"tolerance_m":{"type":"number"},"watersheds":{"type":"array","items":{"$ref":"#/components/schemas/Summary"}},"catalog_tags":{"type":"array","items":{"type":"string"}},"id_version":{"type":"string","const":"v0"},"id_status":{"type":"string","examples":["provisional"]},"source_version":{"type":"string","examples":["J-FlwDir v1.4"]},"credit":{"type":"string"},"license":{"type":"string","examples":["CC BY 4.0"]}},"required":["level","watersheds","catalog_tags","id_version","id_status","source_version","credit","license"]},"Meta":{"type":"object","properties":{"source_url":{"type":"string"},"release":{"type":"object"},"counts":{"type":"object"},"notes":{"type":"object"},"id_version":{"type":"string","const":"v0"},"id_status":{"type":"string","examples":["provisional"]},"source_version":{"type":"string","examples":["J-FlwDir v1.4"]},"credit":{"type":"string"},"license":{"type":"string","examples":["CC BY 4.0"]}},"required":["release","counts","notes","id_version","id_status","source_version","credit","license"]},"Error":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"id":{"type":"string"},"retired_at":{"type":"string"},"successor_id":{"type":"string"},"id_version":{"type":"string","const":"v0"},"id_status":{"type":"string","examples":["provisional"]},"source_version":{"type":"string","examples":["J-FlwDir v1.4"]},"credit":{"type":"string"},"license":{"type":"string","examples":["CC BY 4.0"]}},"required":["error","id_version","id_status","source_version","credit","license"]}}}}