{
  "openapi": "3.1.0",
  "info": {
    "title": "シルギア 健康保険・厚生年金の保険料率API",
    "version": "1.0.0",
    "description": "登録不要・無料の社会保険の保険料率API。協会けんぽ（全国健康保険協会）の47都道府県の健康保険料率（2012年度から最新の年度まで）と、介護保険料率・子ども・子育て支援金率・厚生年金保険料率・子ども・子育て拠出金率・雇用保険料率を、使いはじめる月（effective_from）つきで返します。率の単位はすべて %。年度の境目は項目ごとに違います（健康保険・介護保険は3月分から、支援金は4月分から、雇用保険は4月1日から）。協会けんぽ・日本年金機構・厚生労働省・こども家庭庁の公表値をもとにアナライズギア株式会社が作成（厚生労働省・こども家庭庁の資料は加工して作成）。公式の API ではありません。健康保険組合・共済組合・船員保険の料率は含みません。説明: https://api.shirugear.com/shaho/ 。v1 の中では項目を足すことはあっても、名前や意味は変えません（知らない項目は無視してください）。",
    "termsOfService": "https://api.shirugear.com/terms/",
    "contact": {
      "name": "アナライズギア株式会社（シルギア）",
      "url": "https://shirugear.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://api.shirugear.com"
    }
  ],
  "paths": {
    "/shaho/v1/{key}.json": {
      "get": {
        "summary": "年度の料率（4桁）または都道府県の移り変わり（2桁）",
        "description": "key が年度4桁（2012〜最新の年度）なら FiscalYearResponse、都道府県コード2桁（01〜47）なら PrefectureResponse を返します。",
        "operationId": "getShaho",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "年度4桁（西暦。2012〜最新の年度）または都道府県コード2桁（JIS。01〜47）",
            "schema": {
              "type": "string",
              "pattern": "^([0-9]{2}|[0-9]{4})$"
            },
            "examples": {
              "fiscalYear": {
                "summary": "令和8年度",
                "value": "2026"
              },
              "prefecture": {
                "summary": "東京都",
                "value": "13"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "年度の料率、または都道府県の移り変わり",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/FiscalYearResponse"
                    },
                    {
                      "$ref": "#/components/schemas/PrefectureResponse"
                    }
                  ]
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      }
    },
    "/shaho/v1/all.json": {
      "get": {
        "summary": "全部（全年度の全国一律の率＋47都道府県×全年度の健康保険料率）",
        "operationId": "getShahoAll",
        "responses": {
          "200": {
            "description": "全部",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllResponse"
                }
              }
            }
          }
        }
      }
    },
    "/shaho/v1/meta.json": {
      "get": {
        "summary": "データの版・出典・収録の範囲・件数",
        "operationId": "getShahoMeta",
        "responses": {
          "200": {
            "description": "データの版",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetaResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PrefCode": {
        "type": "string",
        "pattern": "^(0[1-9]|[1-3][0-9]|4[0-7])$",
        "description": "都道府県コード2桁（JIS。01 北海道〜47 沖縄県）"
      },
      "RateSince": {
        "type": "object",
        "required": [
          "rate",
          "effective_from"
        ],
        "properties": {
          "rate": {
            "type": "number",
            "description": "率（%）"
          },
          "effective_from": {
            "type": "string",
            "pattern": "^[0-9]{4}-[0-9]{2}$",
            "description": "この率が使われはじめた月 YYYY-MM"
          }
        }
      },
      "HealthPrefecture": {
        "type": "object",
        "required": [
          "pref_code",
          "pref",
          "rate",
          "rate_with_care",
          "change"
        ],
        "properties": {
          "pref_code": {
            "$ref": "#/components/schemas/PrefCode"
          },
          "pref": {
            "type": "string",
            "description": "都道府県名"
          },
          "rate": {
            "type": "number",
            "description": "協会けんぽの健康保険料率（%・介護保険を含まない）"
          },
          "rate_with_care": {
            "type": "number",
            "description": "rate＋介護保険料率（40〜64歳）"
          },
          "change": {
            "type": [
              "number",
              "null"
            ],
            "description": "前の年度との差（ポイント）。最初の年度は null"
          }
        }
      },
      "HealthHead": {
        "type": "object",
        "required": [
          "effective_from",
          "revised",
          "average_rate",
          "source_url"
        ],
        "properties": {
          "effective_from": {
            "type": "string",
            "pattern": "^[0-9]{4}-[0-9]{2}$",
            "description": "この年度の健康保険料率・介護保険料率を使いはじめる月（ふつう3月分。2015年度は4月分）"
          },
          "revised": {
            "type": "boolean",
            "description": "false=47都道府県とも前の年度と同じ（据え置き）"
          },
          "average_rate": {
            "type": [
              "number",
              "null"
            ],
            "description": "協会けんぽの平均保険料率（公表値）。確かめられた年度だけ。ほかは null"
          },
          "source_url": {
            "type": "string",
            "format": "uri",
            "description": "その年度の料率を確かめた協会けんぽのページ"
          }
        }
      },
      "Health": {
        "allOf": [
          {
            "$ref": "#/components/schemas/HealthHead"
          },
          {
            "type": "object",
            "required": [
              "prefectures"
            ],
            "properties": {
              "prefectures": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/HealthPrefecture"
                },
                "minItems": 47,
                "maxItems": 47
              }
            }
          }
        ]
      },
      "EmploymentRate": {
        "type": "object",
        "required": [
          "type",
          "label",
          "worker",
          "employer",
          "employer_benefits",
          "employer_two_projects",
          "total",
          "per_mille"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "general",
              "agri_sake",
              "construction"
            ],
            "description": "general=一般の事業 / agri_sake=農林水産・清酒製造の事業 / construction=建設の事業"
          },
          "label": {
            "type": "string"
          },
          "worker": {
            "type": "number",
            "description": "労働者負担（%）"
          },
          "employer": {
            "type": "number",
            "description": "事業主負担（%）＝employer_benefits＋employer_two_projects"
          },
          "employer_benefits": {
            "type": "number",
            "description": "事業主負担のうち失業等給付・育児休業給付の分（%）"
          },
          "employer_two_projects": {
            "type": "number",
            "description": "事業主負担のうち雇用保険二事業の分（%）"
          },
          "total": {
            "type": "number",
            "description": "雇用保険料率（%）＝worker＋employer"
          },
          "per_mille": {
            "type": "object",
            "required": [
              "worker",
              "employer",
              "total"
            ],
            "properties": {
              "worker": {
                "type": "number"
              },
              "employer": {
                "type": "number"
              },
              "total": {
                "type": "number"
              }
            },
            "description": "1,000分の◯ の値（5 は 5/1,000＝0.5%）"
          }
        }
      },
      "Employment": {
        "type": "object",
        "required": [
          "effective_from",
          "effective_to",
          "types"
        ],
        "properties": {
          "effective_from": {
            "type": "string",
            "format": "date"
          },
          "effective_to": {
            "type": "string",
            "format": "date"
          },
          "types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmploymentRate"
            }
          }
        }
      },
      "YearRates": {
        "type": "object",
        "required": [
          "fiscal_year",
          "fiscal_year_label",
          "unit",
          "care",
          "child_support",
          "pension",
          "child_contribution",
          "employment"
        ],
        "properties": {
          "fiscal_year": {
            "type": "integer"
          },
          "fiscal_year_label": {
            "type": "string",
            "description": "和暦の年度（令和8年度など。2019年度は令和元年度）"
          },
          "unit": {
            "type": "string",
            "enum": [
              "%"
            ]
          },
          "care": {
            "$ref": "#/components/schemas/RateSince",
            "description": "介護保険料率（協会けんぽ・全国一律）"
          },
          "child_support": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RateSince"
              },
              {
                "type": "null"
              }
            ],
            "description": "子ども・子育て支援金率（2026年4月分から）。始まる前の年度は null"
          },
          "pension": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RateSince"
              },
              {
                "type": "null"
              }
            ],
            "description": "厚生年金保険料率（2017年9月分から18.3%）。2017年度より前は null"
          },
          "child_contribution": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RateSince"
              },
              {
                "type": "null"
              }
            ],
            "description": "子ども・子育て拠出金率（事業主のみ負担）。2019年度より前は null"
          },
          "employment": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Employment"
              },
              {
                "type": "null"
              }
            ],
            "description": "雇用保険料率。2023年度より前は null"
          }
        }
      },
      "FiscalYearResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/YearRates"
          },
          {
            "type": "object",
            "required": [
              "health",
              "data_version"
            ],
            "properties": {
              "health": {
                "$ref": "#/components/schemas/Health"
              },
              "data_version": {
                "type": "string",
                "format": "date"
              }
            }
          }
        ]
      },
      "PrefectureResponse": {
        "type": "object",
        "required": [
          "pref_code",
          "pref",
          "unit",
          "insurer",
          "history",
          "data_version"
        ],
        "properties": {
          "pref_code": {
            "$ref": "#/components/schemas/PrefCode"
          },
          "pref": {
            "type": "string"
          },
          "unit": {
            "type": "string",
            "enum": [
              "%"
            ]
          },
          "insurer": {
            "type": "string"
          },
          "history": {
            "type": "array",
            "description": "新しい年度から順",
            "items": {
              "type": "object",
              "required": [
                "fiscal_year",
                "fiscal_year_label",
                "effective_from",
                "rate",
                "care_rate",
                "rate_with_care",
                "change"
              ],
              "properties": {
                "fiscal_year": {
                  "type": "integer"
                },
                "fiscal_year_label": {
                  "type": "string"
                },
                "effective_from": {
                  "type": "string",
                  "pattern": "^[0-9]{4}-[0-9]{2}$",
                  "description": "YYYY-MM（その月の分の保険料から）"
                },
                "rate": {
                  "type": "number"
                },
                "care_rate": {
                  "type": "number"
                },
                "rate_with_care": {
                  "type": "number"
                },
                "change": {
                  "type": [
                    "number",
                    "null"
                  ]
                }
              }
            }
          },
          "data_version": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "AllResponse": {
        "type": "object",
        "required": [
          "from",
          "to",
          "unit",
          "years",
          "prefectures",
          "data_version"
        ],
        "properties": {
          "from": {
            "type": "integer"
          },
          "to": {
            "type": "integer"
          },
          "unit": {
            "type": "string",
            "enum": [
              "%"
            ]
          },
          "years": {
            "type": "array",
            "description": "古い年度から順。年度の応答から health.prefectures を除いたもの",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/YearRates"
                },
                {
                  "type": "object",
                  "required": [
                    "health"
                  ],
                  "properties": {
                    "health": {
                      "$ref": "#/components/schemas/HealthHead"
                    }
                  }
                }
              ]
            }
          },
          "prefectures": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "pref_code",
                "pref",
                "history"
              ],
              "properties": {
                "pref_code": {
                  "$ref": "#/components/schemas/PrefCode"
                },
                "pref": {
                  "type": "string"
                },
                "history": {
                  "type": "array",
                  "description": "古い年度から順",
                  "items": {
                    "type": "object",
                    "required": [
                      "fiscal_year",
                      "rate"
                    ],
                    "properties": {
                      "fiscal_year": {
                        "type": "integer"
                      },
                      "rate": {
                        "type": "number"
                      }
                    }
                  }
                }
              }
            }
          },
          "data_version": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "MetaResponse": {
        "type": "object",
        "required": [
          "data_version",
          "built_at",
          "from",
          "to",
          "notice",
          "source",
          "attribution",
          "scope",
          "coverage",
          "excel_checked",
          "sources",
          "counts"
        ],
        "properties": {
          "data_version": {
            "type": "string",
            "format": "date"
          },
          "built_at": {
            "type": "string",
            "format": "date-time"
          },
          "from": {
            "type": "integer"
          },
          "to": {
            "type": "integer"
          },
          "notice": {
            "type": "string",
            "description": "作成者と、公式の API ではないことの表示"
          },
          "source": {
            "type": "string"
          },
          "attribution": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scope": {
            "type": "string"
          },
          "coverage": {
            "type": "object",
            "description": "項目ごとに入っている年度"
          },
          "excel_checked": {
            "type": "object",
            "required": [
              "fiscal_year",
              "url",
              "prefectures",
              "mismatches"
            ],
            "properties": {
              "fiscal_year": {
                "type": "integer"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "prefectures": {
                "type": "integer"
              },
              "mismatches": {
                "type": "integer"
              }
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "publisher",
                "url",
                "last_modified",
                "fetched_at"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "last_modified": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "fetched_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "counts": {
            "type": "object",
            "required": [
              "prefectures",
              "fiscal_years",
              "records"
            ],
            "properties": {
              "prefectures": {
                "type": "integer"
              },
              "fiscal_years": {
                "type": "integer"
              },
              "records": {
                "type": "integer"
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "status",
              "code",
              "message"
            ],
            "properties": {
              "status": {
                "type": "integer",
                "enum": [
                  400,
                  403,
                  404,
                  405
                ]
              },
              "code": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "not_found",
                  "region_not_allowed",
                  "method_not_allowed"
                ]
              },
              "message": {
                "type": "string",
                "description": "説明文（言い回しは変わることがあります）"
              }
            }
          }
        }
      }
    }
  }
}
