{
  "openapi": "3.1.0",
  "info": {
    "title": "シルギア 気象庁の予報区・地域コードAPI",
    "version": "1.0.0",
    "description": "登録不要・無料の気象庁の予報区・地域コードAPI。市区町村（自治体コード5桁・6桁、政令市の区も）から、地方予報区（11）・府県予報区（56）・一次細分区域（142）・市町村等をまとめた地域（375）・警報・注意報の発表区域（二次細分区域・1805）のコードと名前を返し、区域のコードからその中の市区町村を返します。コードは気象庁防災情報XMLと同じです。発表中の警報・注意報や天気予報は含みません。出典: 気象庁「気象庁防災情報XMLフォーマット 個別コード表」「細分区域等一覧表」を加工して作成（アナライズギア株式会社。気象庁の公式の API ではありません）。説明: https://api.shirugear.com/jmaarea/ 。v1 の中では項目を追加することはあっても、名前や意味は変えません（知らない項目は無視してください）。",
    "termsOfService": "https://api.shirugear.com/terms/",
    "contact": {
      "name": "アナライズギア株式会社（シルギア）",
      "url": "https://shirugear.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://api.shirugear.com"
    }
  ],
  "paths": {
    "/jmaarea/v1/{code}.json": {
      "get": {
        "summary": "市区町村 → 区域（地方予報区〜警報・注意報の発表区域）",
        "operationId": "getJmaAreaMunicipality",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "自治体コード5桁、または検査数字付き6桁（政令市の区も）",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{5,6}$"
            },
            "example": "13104"
          }
        ],
        "responses": {
          "200": {
            "description": "市区町村が入る区域",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JmaAreaMunicipality"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（code は invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い市区町村コード・区域のコード（都道府県のコード・北方領土の6村・見直しの前の古い区域のコードも 404。code は not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/jmaarea/v1/area/{code}.json": {
      "get": {
        "summary": "区域1件と、その中の市区町村",
        "operationId": "getJmaArea",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "区域のコード。地方予報区5桁・府県予報区／一次細分区域／まとめた地域6桁・警報・注意報の発表区域7桁",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{5,7}$"
            },
            "examples": {
              "warning": {
                "summary": "横浜市南部",
                "value": "1410012"
              },
              "group": {
                "summary": "中部北（静岡県）",
                "value": "220012"
              },
              "region": {
                "summary": "四国地方",
                "value": "10800"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "区域1件",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JmaAreaDetail"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（code は invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い市区町村コード・区域のコード（都道府県のコード・北方領土の6村・見直しの前の古い区域のコードも 404。code は not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/jmaarea/v1/areas.json": {
      "get": {
        "summary": "全区域の木（発表区域ごとの市区町村コードつき）",
        "operationId": "getJmaAreaTree",
        "responses": {
          "200": {
            "description": "全区域",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JmaAreaTree"
                }
              }
            }
          }
        }
      }
    },
    "/jmaarea/v1/meta.json": {
      "get": {
        "summary": "データの版・出典・件数",
        "operationId": "getJmaAreaMeta",
        "responses": {
          "200": {
            "description": "版と件数",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JmaAreaMeta"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AreaRef": {
        "type": "object",
        "required": [
          "code",
          "name"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "WarningArea": {
        "type": "object",
        "required": [
          "code",
          "name",
          "kana",
          "covers",
          "area_text",
          "group_code",
          "primary_code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[0-9]{7}$",
            "description": "警報・注意報の発表区域（二次細分区域）のコード7桁（AreaInformationCity）"
          },
          "name": {
            "type": "string"
          },
          "kana": {
            "type": "string",
            "description": "読み（ひらがな）"
          },
          "covers": {
            "type": "string",
            "enum": [
              "whole",
              "part"
            ],
            "description": "whole＝市区町村の全部がこの区域、part＝一部だけ"
          },
          "area_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "市町村を分けた区域の範囲（気象庁の書き方）。市町村をそのまま区域にしているときは null"
          },
          "group_code": {
            "type": "string",
            "description": "この区域が入る市町村等をまとめた地域のコード"
          },
          "primary_code": {
            "type": "string",
            "description": "この区域が入る一次細分区域のコード"
          }
        }
      },
      "JmaAreaMunicipality": {
        "type": "object",
        "required": [
          "code",
          "code6",
          "name",
          "kind",
          "pref_code",
          "prefecture",
          "parent_code",
          "region",
          "pref_area",
          "primary_areas",
          "groups",
          "warning_areas",
          "split",
          "lgcode",
          "data_version"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "code6": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "city",
              "designated_city",
              "ward",
              "special_ward",
              "town",
              "village"
            ]
          },
          "pref_code": {
            "type": "string"
          },
          "prefecture": {
            "type": "string"
          },
          "parent_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "region": {
            "$ref": "#/components/schemas/AreaRef",
            "description": "地方予報区"
          },
          "pref_area": {
            "$ref": "#/components/schemas/AreaRef",
            "description": "府県予報区"
          },
          "primary_areas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AreaRef"
            },
            "description": "一次細分区域（ふつうは1つ）"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AreaRef"
            },
            "description": "市町村等をまとめた地域（ふつうは1つ）"
          },
          "warning_areas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WarningArea"
            },
            "minItems": 1
          },
          "split": {
            "type": "boolean"
          },
          "lgcode": {
            "type": "string",
            "format": "uri"
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "AreaMunicipality": {
        "type": "object",
        "required": [
          "code",
          "code6",
          "name",
          "kind",
          "pref_code",
          "covers"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "code6": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "pref_code": {
            "type": "string"
          },
          "covers": {
            "type": "string",
            "enum": [
              "whole",
              "part"
            ],
            "description": "whole＝市区町村の全部がこの区域、part＝一部だけ"
          }
        }
      },
      "JmaAreaDetail": {
        "type": "object",
        "required": [
          "code",
          "name",
          "kana",
          "level",
          "level_name",
          "also_levels",
          "municipality_count",
          "municipalities",
          "data_version"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "kana": {
            "type": [
              "string",
              "null"
            ]
          },
          "level": {
            "type": "string",
            "enum": [
              "region",
              "pref_area",
              "primary",
              "group",
              "warning"
            ]
          },
          "level_name": {
            "type": "string"
          },
          "also_levels": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "region",
                "pref_area",
                "primary",
                "group",
                "warning"
              ]
            }
          },
          "region": {
            "$ref": "#/components/schemas/AreaRef"
          },
          "pref_area": {
            "$ref": "#/components/schemas/AreaRef"
          },
          "primary": {
            "$ref": "#/components/schemas/AreaRef"
          },
          "group": {
            "$ref": "#/components/schemas/AreaRef"
          },
          "children": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "level": {
                  "type": "string",
                  "enum": [
                    "region",
                    "pref_area",
                    "primary",
                    "group",
                    "warning"
                  ]
                }
              }
            }
          },
          "area_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "municipality_count": {
            "type": "integer"
          },
          "municipalities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AreaMunicipality"
            }
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "JmaAreaTree": {
        "type": "object",
        "required": [
          "counts",
          "regions",
          "data_version"
        ],
        "properties": {
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "地方予報区 → pref_areas → primaries → groups → warning_areas（各段に code・name・kana。warning_areas には municipalities＝自治体コード5桁の配列）"
            }
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "JmaAreaMeta": {
        "type": "object",
        "required": [
          "data_version",
          "areas_as_of",
          "sources",
          "counts"
        ],
        "properties": {
          "data_version": {
            "type": "string",
            "description": "気象庁のコード表の更新日"
          },
          "areas_as_of": {
            "type": "string",
            "description": "細分区域等一覧表の時点"
          },
          "source": {
            "type": "string"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "license": {
            "type": "string"
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "split_municipalities": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "warning_areas": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "excluded": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "status",
              "code",
              "message"
            ],
            "properties": {
              "status": {
                "type": "integer"
              },
              "code": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "not_found",
                  "method_not_allowed",
                  "region_not_allowed"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
