{
  "openapi": "3.1.0",
  "info": {
    "title": "シルギア 駅API",
    "version": "1.1.0",
    "description": "登録不要・無料の駅API。全国9,046駅の駅名・読み・都道府県・市区町村（自治体コード6桁）・緯度経度・乗り換えられる路線と、603路線の駅の並び、都道府県の駅の一覧を返します。路線の駅の並びは位置から決めたおおよその順です（山手線などの運転系統は駅名の並び）。読みは Wikidata（CC0）のかな表記を駅名と位置で突き合わせたもので、付けられない駅は null です。出典: 「国土数値情報（鉄道データ）」（国土交通省）（https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N02-2025.html）を加工して作成（アナライズギア株式会社）。都道府県・市区町村は「国土数値情報（行政区域データ）」（国土交通省）を加工して決めています。国土交通省や鉄道会社の公式の API ではありません。説明: https://api.shirugear.com/station/ 。v1 の中では項目を足すことはあっても、名前や意味は変えません（知らない項目は無視してください）。",
    "termsOfService": "https://api.shirugear.com/terms/",
    "contact": {
      "name": "アナライズギア株式会社（シルギア）",
      "url": "https://shirugear.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://api.shirugear.com"
    }
  ],
  "paths": {
    "/station/v1/{code}.json": {
      "get": {
        "summary": "駅1件",
        "operationId": "getStation",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "description": "駅のコード（国土数値情報の駅のグループコード・6桁）",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{6}$"
            },
            "example": "003922"
          }
        ],
        "responses": {
          "200": {
            "description": "駅1件",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Station"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（code は invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い駅のコード（code は not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/station/v1/line/{line_id}.json": {
      "get": {
        "summary": "路線1件と駅の並び",
        "operationId": "getLine",
        "parameters": [
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "description": "路線 ID（lines.json で分かる）",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}$"
            },
            "example": "12e493d1"
          }
        ],
        "responses": {
          "200": {
            "description": "路線1件",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Line"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（code は invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い路線 ID（code は not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/station/v1/pref/{pref_code}.json": {
      "get": {
        "summary": "都道府県の駅と路線",
        "operationId": "getPrefStations",
        "parameters": [
          {
            "name": "pref_code",
            "in": "path",
            "required": true,
            "description": "都道府県コード2桁",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{2}$"
            },
            "example": "13"
          }
        ],
        "responses": {
          "200": {
            "description": "都道府県の駅",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrefStations"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う（code は invalid_request）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い都道府県コード（code は not_found）",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/station/v1/near.json": {
      "get": {
        "summary": "緯度経度から近くの駅（近い順・直線距離つき）",
        "operationId": "getNearStations",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "description": "緯度（十進・世界測地系・20〜46）",
            "schema": {
              "type": "string",
              "pattern": "^-?\\d{1,3}(\\.\\d{1,15})?$"
            },
            "example": "35.681236"
          },
          {
            "name": "lng",
            "in": "query",
            "required": true,
            "description": "経度（十進・世界測地系・122〜154）",
            "schema": {
              "type": "string",
              "pattern": "^-?\\d{1,3}(\\.\\d{1,15})?$"
            },
            "example": "139.767125"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "返す駅の数（1〜20・省略時5）",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 5
            }
          },
          {
            "name": "within",
            "in": "query",
            "required": false,
            "description": "この距離（km・0.1〜50）より遠い駅は返さない",
            "schema": {
              "type": "number",
              "minimum": 0.1,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "近くの駅",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NearStations"
                }
              }
            }
          },
          "400": {
            "description": "緯度・経度が無い・範囲の外、limit・within が範囲の外",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/station/v1/names.json": {
      "get": {
        "summary": "全駅の名前・読みの一覧（駅名の順）",
        "operationId": "getStationNames",
        "responses": {
          "200": {
            "description": "全駅",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationNames"
                }
              }
            }
          }
        }
      }
    },
    "/station/v1/points.json": {
      "get": {
        "summary": "全駅の位置の一覧（駅のコードの順）",
        "operationId": "getStationPoints",
        "responses": {
          "200": {
            "description": "全駅の [コード, 駅名, 緯度, 経度]",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationPoints"
                }
              }
            }
          }
        }
      }
    },
    "/station/v1/lines.json": {
      "get": {
        "summary": "全路線の一覧",
        "operationId": "getLines",
        "responses": {
          "200": {
            "description": "全路線",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LineList"
                }
              }
            }
          }
        }
      }
    },
    "/station/v1/meta.json": {
      "get": {
        "summary": "データの版・出典・件数",
        "operationId": "getStationMeta",
        "responses": {
          "200": {
            "description": "版",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationMeta"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "StationBrief": {
        "type": "object",
        "required": [
          "code",
          "name",
          "reading",
          "pref_code",
          "lg_code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[0-9]{6}$"
          },
          "name": {
            "type": "string"
          },
          "reading": {
            "type": [
              "string",
              "null"
            ]
          },
          "pref_code": {
            "type": "string",
            "pattern": "^[0-9]{2}$"
          },
          "lg_code": {
            "type": "string",
            "pattern": "^[0-9]{6}$"
          }
        }
      },
      "StationLine": {
        "type": "object",
        "properties": {
          "line_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}$"
          },
          "operator": {
            "type": "string",
            "description": "事業者の正式な名前"
          },
          "operator_label": {
            "type": "string",
            "description": "事業者のふだんの呼び名"
          },
          "line_name": {
            "type": "string",
            "description": "正式な路線名"
          },
          "name": {
            "type": "string",
            "description": "短い路線名"
          },
          "label": {
            "type": "string",
            "description": "表示用"
          },
          "station_codes": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[0-9]{6}$"
            },
            "description": "この路線のホームの駅コード"
          },
          "operator_kind": {
            "type": "string",
            "enum": [
              "1",
              "2",
              "3",
              "4",
              "5"
            ],
            "description": "1 新幹線・2 JR在来線・3 公営鉄道・4 民営鉄道・5 第三セクター"
          },
          "operator_kind_name": {
            "type": "string"
          },
          "railway_kind": {
            "type": "string",
            "enum": [
              "11",
              "12",
              "13",
              "14",
              "15",
              "16",
              "17",
              "21",
              "22",
              "23",
              "24",
              "25"
            ]
          },
          "railway_kind_name": {
            "type": "string"
          },
          "ridership": {
            "description": "1日あたりの乗降客数（国土数値情報 駅別乗降客数データ）。データに無い駅は null。会社をまたいで足さない",
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "properties": {
                  "year": {
                    "type": "integer"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "other",
                      "none",
                      "private",
                      "nostation"
                    ]
                  },
                  "passengers": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "人/日（status が ok のときだけ）"
                  },
                  "boarding_only": {
                    "type": "boolean",
                    "description": "true なら乗車人員"
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "included_in": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^[0-9]{6}$"
                  },
                  "history": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "year": {
                          "type": "integer"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "ok",
                            "other",
                            "none",
                            "private",
                            "nostation"
                          ]
                        },
                        "passengers": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "boarding_only": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      "ServiceRef": {
        "type": "object",
        "properties": {
          "line_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}$"
          },
          "name": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "Station": {
        "type": "object",
        "required": [
          "code",
          "name",
          "reading",
          "reading_source",
          "pref_code",
          "prefecture",
          "lg_code",
          "city",
          "lat",
          "lng",
          "lines",
          "services",
          "kaishalog",
          "data_version"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[0-9]{6}$",
            "description": "駅のコード（国土数値情報の駅のグループコード）"
          },
          "name": {
            "type": "string",
            "description": "駅名（「駅」は付かない）"
          },
          "reading": {
            "type": [
              "string",
              "null"
            ],
            "description": "読み（ひらがな）。付けられなかった駅は null"
          },
          "reading_source": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "wikidata",
              null
            ]
          },
          "wikidata": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^Q[0-9]+$"
            }
          },
          "pref_code": {
            "type": "string",
            "pattern": "^[0-9]{2}$"
          },
          "prefecture": {
            "type": "string"
          },
          "lg_code": {
            "type": "string",
            "pattern": "^[0-9]{6}$",
            "description": "自治体コード（検査数字付きの6桁。政令市は区）"
          },
          "city": {
            "type": "string"
          },
          "lat": {
            "type": "number"
          },
          "lng": {
            "type": "number"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StationLine"
            }
          },
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceRef"
            },
            "description": "この駅に止まる運転系統（山手線・京浜東北線など）"
          },
          "kaishalog": {
            "type": "string",
            "format": "uri",
            "description": "カイシャログの「この駅の近くの会社」のページ"
          },
          "data_version": {
            "type": "string",
            "description": "国土数値情報（鉄道データ）のデータの基準日"
          }
        }
      },
      "Line": {
        "type": "object",
        "required": [
          "line_id",
          "operator",
          "operator_label",
          "line_name",
          "name",
          "label",
          "official",
          "order",
          "station_count",
          "stations",
          "prefs",
          "kaishalog",
          "data_version"
        ],
        "properties": {
          "line_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}$"
          },
          "operator": {
            "type": "string"
          },
          "operator_label": {
            "type": "string"
          },
          "line_name": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "official": {
            "type": "boolean",
            "description": "国土数値情報にある路線なら true。運転系統として足した路線は false"
          },
          "order": {
            "type": "string",
            "enum": [
              "approximate",
              "service"
            ],
            "description": "approximate＝位置から決めたおおよその順・service＝運転系統の駅名の並び"
          },
          "station_count": {
            "type": "integer"
          },
          "stations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StationBrief"
            }
          },
          "official_stations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StationBrief"
            },
            "description": "山手線・横須賀線だけ。正式な路線の区間の駅"
          },
          "operator_kind": {
            "type": "string"
          },
          "railway_kinds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "prefs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "kaishalog": {
            "type": "string",
            "format": "uri"
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "PrefStations": {
        "type": "object",
        "properties": {
          "pref_code": {
            "type": "string"
          },
          "prefecture": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "stations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "reading": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "lg_code": {
                  "type": "string"
                },
                "city": {
                  "type": "string"
                },
                "lat": {
                  "type": "number"
                },
                "lng": {
                  "type": "number"
                },
                "line_ids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "line_id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "official": {
                  "type": "boolean"
                },
                "station_count_in_pref": {
                  "type": "integer"
                }
              }
            }
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "StationNames": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StationBrief"
            }
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "LineList": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "line_id": {
                  "type": "string"
                },
                "operator": {
                  "type": "string"
                },
                "operator_label": {
                  "type": "string"
                },
                "line_name": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "official": {
                  "type": "boolean"
                },
                "order": {
                  "type": "string",
                  "enum": [
                    "approximate",
                    "service"
                  ]
                },
                "station_count": {
                  "type": "integer"
                },
                "prefs": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "StationMeta": {
        "type": "object",
        "properties": {
          "data_version": {
            "type": "string"
          },
          "n02_version": {
            "type": "string"
          },
          "n03_version": {
            "type": "string"
          },
          "n03_as_of": {
            "type": "string"
          },
          "lgcode_data_version": {
            "type": "string"
          },
          "wikidata_fetched_at": {
            "type": "string"
          },
          "built_at": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "notice": {
            "type": "string"
          },
          "kaishalog": {
            "type": "object"
          },
          "counts": {
            "type": "object"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "NearStations": {
        "type": "object",
        "required": [
          "lat",
          "lng",
          "limit",
          "within_km",
          "count",
          "stations",
          "distance",
          "data_version"
        ],
        "properties": {
          "lat": {
            "type": "number"
          },
          "lng": {
            "type": "number"
          },
          "limit": {
            "type": "integer"
          },
          "within_km": {
            "type": [
              "number",
              "null"
            ]
          },
          "count": {
            "type": "integer"
          },
          "stations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "code",
                "name",
                "reading",
                "distance_m",
                "pref_code",
                "prefecture",
                "lg_code",
                "city",
                "lat",
                "lng",
                "lines",
                "url",
                "kaishalog"
              ],
              "properties": {
                "code": {
                  "type": "string",
                  "pattern": "^\\d{6}$"
                },
                "name": {
                  "type": "string"
                },
                "reading": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "distance_m": {
                  "type": "integer",
                  "description": "直線距離（m・大円距離）"
                },
                "pref_code": {
                  "type": "string"
                },
                "prefecture": {
                  "type": "string"
                },
                "lg_code": {
                  "type": "string"
                },
                "city": {
                  "type": "string"
                },
                "lat": {
                  "type": "number"
                },
                "lng": {
                  "type": "number"
                },
                "lines": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "line_id": {
                        "type": "string"
                      },
                      "label": {
                        "type": "string"
                      }
                    }
                  }
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "kaishalog": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "distance": {
            "type": "string"
          },
          "data_version": {
            "type": "string"
          }
        }
      },
      "StationPoints": {
        "type": "object",
        "required": [
          "count",
          "fields",
          "items",
          "data_version"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "code",
              "name",
              "lat",
              "lng"
            ]
          },
          "items": {
            "type": "array",
            "items": {
              "type": "array",
              "prefixItems": [
                {
                  "type": "string"
                },
                {
                  "type": "string"
                },
                {
                  "type": "number"
                },
                {
                  "type": "number"
                }
              ]
            }
          },
          "data_version": {
            "type": "string"
          }
        }
      }
    }
  }
}
