{
  "openapi": "3.1.0",
  "info": {
    "title": "シルギア 気温・降水量の平年値API",
    "version": "1.0.0",
    "description": "登録不要・無料の平年値API。全国のアメダス・気象台など1,273地点の、月ごと（months: 1月〜12月）と年（year）の平年値（平均気温・日最高気温・日最低気温・降水量・日照時間・風速・積雪・夏日などの日数。気象台などは湿度・降雪の深さ・日射量も）を返します。市区町村ごとに役所にいちばん近い地点（気温用・降水量用）、都道府県ごとの一覧もあります。平年値は過去30年（1991〜2020年）の平均で、予想や予報ではありません。雪の年の値は寒候年（前年8月〜その年7月）。アメダスの多くの地点の日照時間は推計値（estimated: true）。出典: 気象庁ホームページ（https://www.data.jma.go.jp/stats/data/mdrr/normal/index.html）の2020年平年値を加工して作成（アナライズギア株式会社）。気象庁の公式のAPIではありません。説明: https://api.shirugear.com/heinen/ 。v1 の中では項目を足すことはあっても、名前や意味は変えません（知らない項目は無視してください）。",
    "termsOfService": "https://api.shirugear.com/terms/",
    "contact": {
      "name": "アナライズギア株式会社（シルギア）",
      "url": "https://shirugear.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://api.shirugear.com"
    }
  ],
  "paths": {
    "/heinen/v1/{id}.json": {
      "get": {
        "summary": "地点の月ごとと年の平年値",
        "operationId": "getHeinenStation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "地点番号（アメダスの観測所番号5桁）",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{5}$"
            },
            "example": "44132"
          }
        ],
        "responses": {
          "200": {
            "description": "地点の平年値",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationResponse"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い地点・都道府県・市区町村（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外からのアクセス（region_not_allowed）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/heinen/v1/stations.json": {
      "get": {
        "summary": "全地点の一覧",
        "operationId": "getHeinenStations",
        "responses": {
          "200": {
            "description": "全地点",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationsResponse"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外からのアクセス（region_not_allowed）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/heinen/v1/pref/{pref}.json": {
      "get": {
        "summary": "都道府県の地点の一覧と代表の地点",
        "operationId": "getHeinenPref",
        "parameters": [
          {
            "name": "pref",
            "in": "path",
            "required": true,
            "description": "都道府県コード2桁（01〜47）",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{2}$"
            },
            "example": "13"
          }
        ],
        "responses": {
          "200": {
            "description": "都道府県",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrefResponse"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い地点・都道府県・市区町村（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外からのアクセス（region_not_allowed）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/heinen/v1/city/{code6}.json": {
      "get": {
        "summary": "市区町村の役所にいちばん近い地点（気温用・降水量用）",
        "operationId": "getHeinenCity",
        "parameters": [
          {
            "name": "code6",
            "in": "path",
            "required": true,
            "description": "検査数字つき6桁の自治体コード",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{6}$"
            },
            "example": "131016"
          }
        ],
        "responses": {
          "200": {
            "description": "市区町村",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CityResponse"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い地点・都道府県・市区町村（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外からのアクセス（region_not_allowed）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/heinen/v1/cities.json": {
      "get": {
        "summary": "全市区町村の最寄りの地点の一覧",
        "operationId": "getHeinenCities",
        "responses": {
          "200": {
            "description": "全市区町村",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CitiesResponse"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外からのアクセス（region_not_allowed）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/heinen/v1/meta.json": {
      "get": {
        "summary": "データの版・出典・項目の説明・件数",
        "operationId": "getHeinenMeta",
        "responses": {
          "200": {
            "description": "版",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetaResponse"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外からのアクセス（region_not_allowed）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "StationId": {
        "type": "string",
        "pattern": "^[0-9]{5}$",
        "description": "地点番号（アメダスの観測所番号5桁。阿蘇山だけは 47821）",
        "example": "44132"
      },
      "PrefCode": {
        "type": "string",
        "pattern": "^[0-9]{2}$",
        "description": "都道府県コード2桁（JIS）",
        "example": "13"
      },
      "Normal": {
        "type": "object",
        "required": [
          "months",
          "year"
        ],
        "properties": {
          "months": {
            "type": "array",
            "minItems": 12,
            "maxItems": 12,
            "items": {
              "type": [
                "number",
                "null"
              ]
            },
            "description": "1月〜12月（[0] が1月）"
          },
          "year": {
            "type": [
              "number",
              "null"
            ],
            "description": "年の値（平均・合計。雪の項目は寒候年）"
          },
          "estimated": {
            "type": "boolean",
            "const": true,
            "description": "日照時間が推計値のときだけ"
          },
          "reference": {
            "type": "boolean",
            "const": true,
            "description": "気象庁が［参考］としている値のときだけ"
          },
          "years": {
            "type": "integer",
            "description": "もとになった年数（30年と違うときだけ）"
          },
          "from": {
            "type": "integer"
          },
          "to": {
            "type": "integer"
          }
        }
      },
      "Normals": {
        "type": "object",
        "description": "その地点にある項目だけが入ります",
        "properties": {
          "temp": {
            "$ref": "#/components/schemas/Normal",
            "description": "平均気温（℃）"
          },
          "temp_max": {
            "$ref": "#/components/schemas/Normal",
            "description": "日最高気温の平均（℃）"
          },
          "temp_min": {
            "$ref": "#/components/schemas/Normal",
            "description": "日最低気温の平均（℃）"
          },
          "precip": {
            "$ref": "#/components/schemas/Normal",
            "description": "降水量の合計（mm）"
          },
          "sunshine": {
            "$ref": "#/components/schemas/Normal",
            "description": "日照時間の合計（時間）"
          },
          "wind": {
            "$ref": "#/components/schemas/Normal",
            "description": "平均風速（m/s）"
          },
          "humidity": {
            "$ref": "#/components/schemas/Normal",
            "description": "平均の相対湿度（%）"
          },
          "solar_radiation": {
            "$ref": "#/components/schemas/Normal",
            "description": "全天日射量（1日の合計の平均）（MJ/m²）"
          },
          "snowfall": {
            "$ref": "#/components/schemas/Normal",
            "description": "降雪の深さの合計（cm）"
          },
          "snow_depth_max": {
            "$ref": "#/components/schemas/Normal",
            "description": "最深積雪（積雪の深さの最大）（cm）"
          },
          "days_max_lt_0": {
            "$ref": "#/components/schemas/Normal",
            "description": "真冬日（日最高気温が0℃未満）の日数（日）"
          },
          "days_min_lt_0": {
            "$ref": "#/components/schemas/Normal",
            "description": "冬日（日最低気温が0℃未満）の日数（日）"
          },
          "days_max_ge_25": {
            "$ref": "#/components/schemas/Normal",
            "description": "夏日（日最高気温が25℃以上）の日数（日）"
          },
          "days_max_ge_30": {
            "$ref": "#/components/schemas/Normal",
            "description": "真夏日（日最高気温が30℃以上）の日数（日）"
          },
          "days_max_ge_35": {
            "$ref": "#/components/schemas/Normal",
            "description": "猛暑日（日最高気温が35℃以上）の日数（日）"
          },
          "days_min_ge_25": {
            "$ref": "#/components/schemas/Normal",
            "description": "日最低気温が25℃以上の日数（日）"
          },
          "days_precip_ge_1": {
            "$ref": "#/components/schemas/Normal",
            "description": "日降水量が1mm以上の日数（日）"
          },
          "days_precip_ge_10": {
            "$ref": "#/components/schemas/Normal",
            "description": "日降水量が10mm以上の日数（日）"
          }
        }
      },
      "StationResponse": {
        "type": "object",
        "required": [
          "id",
          "name",
          "name_kana",
          "name_romaji",
          "pref_code",
          "pref",
          "lat",
          "lon",
          "alt",
          "surface_id",
          "duplicate_of",
          "normals",
          "period",
          "data_version"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/StationId"
          },
          "name": {
            "type": "string",
            "example": "東京"
          },
          "name_kana": {
            "type": "string",
            "example": "トウキョウ"
          },
          "name_romaji": {
            "type": "string",
            "example": "TOKYO"
          },
          "pref_code": {
            "$ref": "#/components/schemas/PrefCode"
          },
          "pref": {
            "type": "string",
            "example": "東京都"
          },
          "lat": {
            "type": "number",
            "example": 35.6917
          },
          "lon": {
            "type": "number",
            "example": 139.75
          },
          "alt": {
            "type": "number",
            "description": "標高（m）",
            "example": 25
          },
          "surface_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "同じ場所の気象台・特別地域気象観測所の地点番号",
            "example": "47662"
          },
          "duplicate_of": {
            "type": [
              "string",
              "null"
            ],
            "description": "同じ地点・同じ平年値のもう一方の番号。ふつうは null"
          },
          "normals": {
            "$ref": "#/components/schemas/Normals"
          },
          "period": {
            "type": "string",
            "const": "1991-2020"
          },
          "data_version": {
            "type": "string",
            "example": "2020年平年値（第5版）"
          }
        }
      },
      "StationsResponse": {
        "type": "object",
        "required": [
          "count",
          "items"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "$ref": "#/components/schemas/StationId"
                },
                "name": {
                  "type": "string",
                  "example": "東京"
                },
                "name_kana": {
                  "type": "string",
                  "example": "トウキョウ"
                },
                "name_romaji": {
                  "type": "string",
                  "example": "TOKYO"
                },
                "pref_code": {
                  "$ref": "#/components/schemas/PrefCode"
                },
                "pref": {
                  "type": "string",
                  "example": "東京都"
                },
                "lat": {
                  "type": "number",
                  "example": 35.6917
                },
                "lon": {
                  "type": "number",
                  "example": 139.75
                },
                "alt": {
                  "type": "number",
                  "description": "標高（m）",
                  "example": 25
                },
                "surface_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "同じ場所の気象台・特別地域気象観測所の地点番号",
                  "example": "47662"
                },
                "duplicate_of": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "同じ地点・同じ平年値のもう一方の番号。ふつうは null"
                },
                "elements": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "temp",
                      "temp_max",
                      "temp_min",
                      "precip",
                      "sunshine",
                      "wind",
                      "humidity",
                      "solar_radiation",
                      "snowfall",
                      "snow_depth_max",
                      "days_max_lt_0",
                      "days_min_lt_0",
                      "days_max_ge_25",
                      "days_max_ge_30",
                      "days_max_ge_35",
                      "days_min_ge_25",
                      "days_precip_ge_1",
                      "days_precip_ge_10"
                    ]
                  }
                },
                "sunshine_estimated": {
                  "type": "boolean"
                },
                "reference": {
                  "type": "boolean"
                }
              }
            }
          },
          "period": {
            "type": "string",
            "const": "1991-2020"
          },
          "data_version": {
            "type": "string",
            "example": "2020年平年値（第5版）"
          }
        }
      },
      "PrefResponse": {
        "type": "object",
        "required": [
          "pref_code",
          "pref",
          "representative",
          "count",
          "stations"
        ],
        "properties": {
          "pref_code": {
            "$ref": "#/components/schemas/PrefCode"
          },
          "pref": {
            "type": "string"
          },
          "representative": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StationRef"
              },
              {
                "type": "object",
                "properties": {
                  "capital": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            ],
            "description": "都道府県庁のある市区町村の役所にいちばん近い、気温を観測している地点"
          },
          "count": {
            "type": "integer"
          },
          "stations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "$ref": "#/components/schemas/StationId"
                },
                "name": {
                  "type": "string"
                },
                "name_kana": {
                  "type": "string"
                },
                "alt": {
                  "type": "number"
                },
                "lat": {
                  "type": "number"
                },
                "lon": {
                  "type": "number"
                },
                "duplicate_of": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "year": {
                  "type": "object",
                  "additionalProperties": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                }
              }
            }
          },
          "period": {
            "type": "string",
            "const": "1991-2020"
          },
          "data_version": {
            "type": "string",
            "example": "2020年平年値（第5版）"
          }
        }
      },
      "StationRef": {
        "type": "object",
        "required": [
          "id",
          "name",
          "name_kana",
          "pref_code",
          "alt",
          "distance_km",
          "normals"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/StationId"
          },
          "name": {
            "type": "string"
          },
          "name_kana": {
            "type": "string"
          },
          "pref_code": {
            "$ref": "#/components/schemas/PrefCode"
          },
          "alt": {
            "type": "number"
          },
          "distance_km": {
            "type": "number",
            "description": "役所からの距離（km・直線）"
          },
          "normals": {
            "$ref": "#/components/schemas/Normals"
          }
        }
      },
      "CityResponse": {
        "type": "object",
        "required": [
          "code",
          "code6",
          "name",
          "kind",
          "pref_code",
          "pref",
          "temperature",
          "precipitation"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[0-9]{5}$"
          },
          "code6": {
            "type": "string",
            "pattern": "^[0-9]{6}$"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "pref_code": {
            "$ref": "#/components/schemas/PrefCode"
          },
          "pref": {
            "type": "string"
          },
          "temperature": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StationRef"
              },
              {
                "type": "null"
              }
            ],
            "description": "気温を観測している地点のうち、役所にいちばん近い地点"
          },
          "precipitation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StationRef"
              },
              {
                "type": "null"
              }
            ],
            "description": "降水量を観測している地点のうち、役所にいちばん近い地点"
          },
          "note": {
            "type": "string",
            "description": "最寄りの地点を選べなかった理由"
          },
          "period": {
            "type": "string",
            "const": "1991-2020"
          },
          "data_version": {
            "type": "string",
            "example": "2020年平年値（第5版）"
          }
        }
      },
      "CitiesResponse": {
        "type": "object",
        "required": [
          "count",
          "items"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "pattern": "^[0-9]{5}$"
                },
                "code6": {
                  "type": "string",
                  "pattern": "^[0-9]{6}$"
                },
                "name": {
                  "type": "string"
                },
                "kind": {
                  "type": "string"
                },
                "pref_code": {
                  "$ref": "#/components/schemas/PrefCode"
                },
                "pref": {
                  "type": "string"
                },
                "temperature": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "id": {
                      "$ref": "#/components/schemas/StationId"
                    },
                    "distance_km": {
                      "type": "number"
                    }
                  }
                },
                "precipitation": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "id": {
                      "$ref": "#/components/schemas/StationId"
                    },
                    "distance_km": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "period": {
            "type": "string",
            "const": "1991-2020"
          },
          "data_version": {
            "type": "string",
            "example": "2020年平年値（第5版）"
          }
        }
      },
      "MetaResponse": {
        "type": "object",
        "required": [
          "data_version",
          "valid_from",
          "period",
          "source",
          "sources",
          "elements",
          "counts"
        ],
        "properties": {
          "data_version": {
            "type": "string"
          },
          "valid_from": {
            "type": "string",
            "format": "date"
          },
          "period": {
            "type": "object",
            "properties": {
              "from": {
                "type": "integer"
              },
              "to": {
                "type": "integer"
              }
            }
          },
          "source": {
            "type": "string"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "elements": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "notes": {
            "type": "object"
          },
          "counts": {
            "type": "object"
          },
          "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",
                  "region_not_allowed",
                  "not_found",
                  "method_not_allowed"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
