{
  "openapi": "3.1.0",
  "info": {
    "title": "シルギア 消費者物価指数API",
    "version": "1.0.0",
    "description": "登録不要・無料の消費者物価指数（CPI）API。総務省統計局の消費者物価指数（全国・2025年基準）の年平均と月ごとの指数（2025年=100）と前年比・前年同月比を、総合・生鮮食品を除く総合・生鮮食品及びエネルギーを除く総合・食料（酒類を除く）及びエネルギーを除く総合は1970年から、持家の帰属家賃を除く総合は1946年8月から返します。2024年12月以前は旧基準の指数を2025年=100に換算した接続指数です。前年比・前年同月比は統計局の公表値で、指数から計算し直した値とは一致しないことがあります。出典: 総務省統計局「消費者物価指数」2025年基準 長期時系列データ（政府統計の総合窓口〈e-Stat〉）を加工して作成。説明: https://api.shirugear.com/cpi/ 。v1 の中では項目を足すことはあっても、名前や意味は変えません（知らない項目は無視してください）。",
    "termsOfService": "https://api.shirugear.com/terms/",
    "contact": {
      "name": "アナライズギア株式会社（シルギア）",
      "url": "https://shirugear.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://api.shirugear.com"
    }
  ],
  "paths": {
    "/cpi/v1/annual.json": {
      "get": {
        "summary": "年平均の指数と前年比（全部の年）",
        "operationId": "getCpiAnnual",
        "responses": {
          "200": {
            "description": "年平均（古い年から順）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnnualResponse"
                }
              }
            }
          },
          "404": {
            "description": "無いファイル（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/cpi/v1/monthly.json": {
      "get": {
        "summary": "月ごとの指数と前年同月比（全部の月・約250KB）",
        "operationId": "getCpiMonthly",
        "responses": {
          "200": {
            "description": "月ごと（古い月から順）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MonthlyResponse"
                }
              }
            }
          },
          "404": {
            "description": "無いファイル（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/cpi/v1/{year}.json": {
      "get": {
        "summary": "その年の年平均と各月",
        "operationId": "getCpiYear",
        "parameters": [
          {
            "name": "year",
            "in": "path",
            "required": true,
            "description": "西暦4桁（1946〜最新の月の年）",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{4}$"
            },
            "example": "2025"
          }
        ],
        "responses": {
          "200": {
            "description": "その年",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/YearResponse"
                }
              }
            }
          },
          "404": {
            "description": "無いファイル（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/cpi/v1/latest.json": {
      "get": {
        "summary": "いちばん新しい月と年平均",
        "operationId": "getCpiLatest",
        "responses": {
          "200": {
            "description": "最新",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LatestResponse"
                }
              }
            }
          },
          "404": {
            "description": "無いファイル（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/cpi/v1/meta.json": {
      "get": {
        "summary": "データの版・基準年・系列・出典・件数",
        "operationId": "getCpiMeta",
        "responses": {
          "200": {
            "description": "データの版",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetaResponse"
                }
              }
            }
          },
          "404": {
            "description": "無いファイル（not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SeriesKey": {
        "type": "string",
        "enum": [
          "all",
          "less_fresh_food",
          "less_fresh_food_energy",
          "less_food_energy",
          "less_imputed_rent"
        ]
      },
      "BySeries": {
        "type": "object",
        "required": [
          "all",
          "less_fresh_food",
          "less_fresh_food_energy",
          "less_food_energy",
          "less_imputed_rent"
        ],
        "properties": {
          "all": {
            "type": [
              "number",
              "null"
            ]
          },
          "less_fresh_food": {
            "type": [
              "number",
              "null"
            ]
          },
          "less_fresh_food_energy": {
            "type": [
              "number",
              "null"
            ]
          },
          "less_food_energy": {
            "type": [
              "number",
              "null"
            ]
          },
          "less_imputed_rent": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "description": "系列ごとの値。値が無い期間は null"
      },
      "Series": {
        "type": "object",
        "required": [
          "key",
          "code",
          "name",
          "name_en",
          "monthly_from",
          "annual_from"
        ],
        "properties": {
          "key": {
            "$ref": "#/components/schemas/SeriesKey"
          },
          "code": {
            "type": "string",
            "description": "統計局の類・品目符号",
            "example": "0001"
          },
          "name": {
            "type": "string",
            "example": "総合"
          },
          "name_en": {
            "type": "string",
            "example": "All items"
          },
          "monthly_from": {
            "type": "string",
            "example": "1970-01"
          },
          "annual_from": {
            "type": "integer",
            "example": 1970
          }
        }
      },
      "Values": {
        "type": "object",
        "required": [
          "index",
          "yoy"
        ],
        "properties": {
          "index": {
            "$ref": "#/components/schemas/BySeries",
            "description": "指数（2025年=100・小数第1位）"
          },
          "yoy": {
            "$ref": "#/components/schemas/BySeries",
            "description": "前年比（年）・前年同月比（月）。%・統計局の公表値"
          }
        }
      },
      "AnnualRow": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Values"
          },
          {
            "type": "object",
            "required": [
              "year"
            ],
            "properties": {
              "year": {
                "type": "integer",
                "example": 2025
              }
            }
          }
        ]
      },
      "MonthlyRow": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Values"
          },
          {
            "type": "object",
            "required": [
              "month"
            ],
            "properties": {
              "month": {
                "type": "string",
                "pattern": "^[0-9]{4}-[0-9]{2}$",
                "example": "2026-10"
              }
            }
          }
        ]
      },
      "AnnualResponse": {
        "type": "object",
        "required": [
          "base_year",
          "unit",
          "area",
          "from",
          "to",
          "series",
          "years",
          "data_version"
        ],
        "properties": {
          "base_year": {
            "type": "integer",
            "example": 2025
          },
          "unit": {
            "type": "string",
            "example": "2025年=100"
          },
          "area": {
            "type": "string",
            "example": "全国"
          },
          "data_version": {
            "type": "string",
            "description": "統計局のデータを取り込んだ日（日本時間）",
            "example": "2026-12-01"
          },
          "from": {
            "type": "integer"
          },
          "to": {
            "type": "integer"
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Series"
            }
          },
          "years": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnnualRow"
            }
          }
        }
      },
      "MonthlyResponse": {
        "type": "object",
        "required": [
          "base_year",
          "unit",
          "area",
          "from",
          "to",
          "series",
          "months",
          "data_version"
        ],
        "properties": {
          "base_year": {
            "type": "integer",
            "example": 2025
          },
          "unit": {
            "type": "string",
            "example": "2025年=100"
          },
          "area": {
            "type": "string",
            "example": "全国"
          },
          "data_version": {
            "type": "string",
            "description": "統計局のデータを取り込んだ日（日本時間）",
            "example": "2026-12-01"
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Series"
            }
          },
          "months": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthlyRow"
            }
          }
        }
      },
      "YearResponse": {
        "type": "object",
        "required": [
          "year",
          "base_year",
          "unit",
          "area",
          "annual",
          "months",
          "complete",
          "data_version"
        ],
        "properties": {
          "base_year": {
            "type": "integer",
            "example": 2025
          },
          "unit": {
            "type": "string",
            "example": "2025年=100"
          },
          "area": {
            "type": "string",
            "example": "全国"
          },
          "data_version": {
            "type": "string",
            "description": "統計局のデータを取り込んだ日（日本時間）",
            "example": "2026-12-01"
          },
          "year": {
            "type": "integer"
          },
          "annual": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Values"
              },
              {
                "type": "null"
              }
            ],
            "description": "年平均。まだ公表されていない年は null"
          },
          "months": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthlyRow"
            }
          },
          "complete": {
            "type": "boolean",
            "description": "12か月と年平均がそろっているか"
          }
        }
      },
      "LatestResponse": {
        "type": "object",
        "required": [
          "base_year",
          "unit",
          "area",
          "month",
          "year",
          "series",
          "data_version"
        ],
        "properties": {
          "base_year": {
            "type": "integer",
            "example": 2025
          },
          "unit": {
            "type": "string",
            "example": "2025年=100"
          },
          "area": {
            "type": "string",
            "example": "全国"
          },
          "data_version": {
            "type": "string",
            "description": "統計局のデータを取り込んだ日（日本時間）",
            "example": "2026-12-01"
          },
          "month": {
            "$ref": "#/components/schemas/MonthlyRow"
          },
          "year": {
            "$ref": "#/components/schemas/AnnualRow"
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Series"
            }
          }
        }
      },
      "MetaResponse": {
        "type": "object",
        "required": [
          "data_version",
          "base_year",
          "latest_month",
          "latest_year",
          "series",
          "source",
          "sources",
          "counts"
        ],
        "properties": {
          "base_year": {
            "type": "integer",
            "example": 2025
          },
          "unit": {
            "type": "string",
            "example": "2025年=100"
          },
          "area": {
            "type": "string",
            "example": "全国"
          },
          "data_version": {
            "type": "string",
            "description": "統計局のデータを取り込んだ日（日本時間）",
            "example": "2026-12-01"
          },
          "latest_month": {
            "type": "string",
            "example": "2026-10"
          },
          "latest_year": {
            "type": "integer",
            "example": 2025
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Series"
            }
          },
          "years": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "files": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "source": {
            "type": "string"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "counts": {
            "type": "object"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "status",
              "code",
              "message"
            ],
            "properties": {
              "status": {
                "type": "integer"
              },
              "code": {
                "type": "string",
                "example": "not_found"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
