{
  "openapi": "3.0.3",
  "info": {
    "title": "地番マスター API",
    "version": "1.0.0",
    "description": "デジタル庁の地番マスターを取得できます。lg_code・machiaza_id・prc_id で関連データと照合できます。"
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "paths": {
    "/v1/parcels.json": {
      "get": {
        "summary": "全国の取得索引",
        "description": "parts の順に各 path を取得し、0始まりの start から count 件を読み取ると、元CSVの順に取得できます。",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "1回に取得する最大件数。",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "取得を始める位置（0から数えます）。",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "JSON データ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rowCount",
                    "parts"
                  ],
                  "properties": {
                    "rowCount": {
                      "type": "integer"
                    },
                    "parts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "path",
                          "start",
                          "count"
                        ],
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "start": {
                            "type": "integer"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                },
                "description": "取得対象の総件数"
              },
              "X-Returned-Count": {
                "schema": {
                  "type": "integer"
                },
                "description": "応答に含まれる件数"
              },
              "X-Next-Offset": {
                "schema": {
                  "type": "integer"
                },
                "description": "次のリクエストに渡す offset の値"
              }
            }
          },
          "400": {
            "description": "不正な limit または offset"
          },
          "422": {
            "description": "単一項目が1 MiBを超えます"
          }
        }
      }
    },
    "/v1/parcels/{lg_code}.json": {
      "get": {
        "summary": "市区町村別の取得索引",
        "description": "parts の順に各 path を取得し、0始まりの start から count 件を読み取ると、元CSVの順に取得できます。",
        "parameters": [
          {
            "description": "市区町村一覧の lg_code（6桁）をそのまま指定します。",
            "name": "lg_code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{6}$",
              "example": "131016"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "1回に取得する最大件数。",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "取得を始める位置（0から数えます）。",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "JSON データ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rowCount",
                    "parts"
                  ],
                  "properties": {
                    "rowCount": {
                      "type": "integer"
                    },
                    "parts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "path",
                          "start",
                          "count"
                        ],
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "start": {
                            "type": "integer"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                },
                "description": "取得対象の総件数"
              },
              "X-Returned-Count": {
                "schema": {
                  "type": "integer"
                },
                "description": "応答に含まれる件数"
              },
              "X-Next-Offset": {
                "schema": {
                  "type": "integer"
                },
                "description": "次のリクエストに渡す offset の値"
              }
            }
          },
          "400": {
            "description": "不正な limit または offset"
          },
          "404": {
            "description": "指定されたデータがありません"
          },
          "422": {
            "description": "単一項目が1 MiBを超えます"
          }
        }
      }
    },
    "/v1/parcels/{lg_code}/{page}.json": {
      "get": {
        "summary": "住居データをページ単位で取得",
        "description": "元CSVの列と値を保持した行の配列を返します。非圧縮のJSONは最大1 MiBです。ページ番号は最新の索引から取得してください。",
        "parameters": [
          {
            "description": "市区町村一覧の lg_code（6桁）をそのまま指定します。",
            "name": "lg_code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{6}$",
              "example": "131016"
            }
          },
          {
            "name": "page",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "example": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "1回に取得する最大件数。",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "取得を始める位置（0から数えます）。",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "JSON データ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Residence"
                  }
                }
              }
            },
            "headers": {
              "X-Total-Count": {
                "schema": {
                  "type": "integer"
                },
                "description": "取得対象の総件数"
              },
              "X-Returned-Count": {
                "schema": {
                  "type": "integer"
                },
                "description": "応答に含まれる件数"
              },
              "X-Next-Offset": {
                "schema": {
                  "type": "integer"
                },
                "description": "次のリクエストに渡す offset の値"
              }
            }
          },
          "400": {
            "description": "不正な limit または offset"
          },
          "404": {
            "description": "指定されたデータがありません"
          },
          "422": {
            "description": "単一項目が1 MiBを超えます"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Residence": {
        "type": "object",
        "required": [
          "lg_code",
          "machiaza_id",
          "prc_id",
          "city",
          "ward",
          "oaza_cho",
          "chome",
          "koaza",
          "machiaza_dist",
          "prc_num1",
          "prc_num2",
          "prc_num3",
          "rsdt_addr_flg",
          "prc_rec_flg",
          "prc_area_code",
          "efct_date",
          "ablt_date",
          "src_code",
          "remarks",
          "real_prop_num"
        ],
        "additionalProperties": false,
        "properties": {
          "lg_code": {
            "type": "string"
          },
          "machiaza_id": {
            "type": "string"
          },
          "prc_id": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "ward": {
            "type": "string"
          },
          "oaza_cho": {
            "type": "string"
          },
          "chome": {
            "type": "string"
          },
          "koaza": {
            "type": "string"
          },
          "machiaza_dist": {
            "type": "string"
          },
          "prc_num1": {
            "type": "string"
          },
          "prc_num2": {
            "type": "string"
          },
          "prc_num3": {
            "type": "string"
          },
          "rsdt_addr_flg": {
            "type": "string"
          },
          "prc_rec_flg": {
            "type": "string"
          },
          "prc_area_code": {
            "type": "string"
          },
          "efct_date": {
            "type": "string"
          },
          "ablt_date": {
            "type": "string"
          },
          "src_code": {
            "type": "string"
          },
          "remarks": {
            "type": "string"
          },
          "real_prop_num": {
            "type": "string"
          }
        }
      }
    }
  }
}
