{
  "openapi": "3.1.0",
  "info": {
    "title": "Tideglass API",
    "version": "1.0.0",
    "description": "Fictional coastal observation API for sensor stations and water measurements. All records are illustrative and the example server is reserved."
  },
  "servers": [
    {
      "url": "https://api.tideglass.example",
      "description": "Fictional server"
    }
  ],
  "paths": {
    "/v1/stations": {
      "get": {
        "operationId": "list-stations",
        "summary": "List stations",
        "description": "Find coastal stations in ascending ID order. Use the returned station ID to read its observations.",
        "parameters": [
          {
            "name": "coast",
            "in": "query",
            "required": false,
            "description": "Filter stations by coastline.",
            "schema": {
              "type": "string",
              "enum": [
                "north",
                "south"
              ]
            },
            "example": "north"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "example": 1
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from the previous page. Omit it on the first request.",
            "schema": {
              "type": "string"
            },
            "example": "c3RhdGlvbi0y"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of coastal stations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StationPage"
                },
                "example": {
                  "data": [
                    {
                      "id": "saltmere-pier",
                      "name": "Saltmere Pier",
                      "coast": "north"
                    }
                  ],
                  "next_cursor": "c3RhdGlvbi0y"
                }
              }
            }
          },
          "400": {
            "description": "The cursor or filter is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "invalid_query",
                  "message": "The cursor or filter is invalid."
                }
              }
            }
          }
        }
      }
    },
    "/v1/stations/{stationId}/observations": {
      "get": {
        "operationId": "list-observations",
        "summary": "List observations",
        "description": "Read water level and temperature measurements for one station, with the newest observation first. Water level is measured above the station’s local chart datum.",
        "parameters": [
          {
            "name": "stationId",
            "in": "path",
            "required": true,
            "description": "Station ID returned by List stations.",
            "schema": {
              "type": "string"
            },
            "example": "saltmere-pier"
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Include observations at or after this UTC timestamp.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-06-18T00:00:00Z"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "example": 1
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from the previous page. Omit it on the first request.",
            "schema": {
              "type": "string"
            },
            "example": "c3RhdGlvbi0y"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of observations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ObservationPage"
                },
                "example": {
                  "data": [
                    {
                      "observed_at": "2026-06-18T08:15:00Z",
                      "water_level_m": 1.42,
                      "water_temperature_c": 13.8
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "The cursor or timestamp is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "invalid_query",
                  "message": "The cursor or timestamp is invalid."
                }
              }
            }
          },
          "404": {
            "description": "The requested station does not exist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "station_not_found",
                  "message": "The requested station does not exist."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Station": {
        "type": "object",
        "required": [
          "id",
          "name",
          "coast"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "coast": {
            "type": "string",
            "enum": [
              "north",
              "south"
            ]
          }
        }
      },
      "Observation": {
        "type": "object",
        "required": [
          "observed_at",
          "water_level_m",
          "water_temperature_c"
        ],
        "properties": {
          "observed_at": {
            "type": "string",
            "format": "date-time"
          },
          "water_level_m": {
            "type": "number",
            "description": "Height in meters above local chart datum."
          },
          "water_temperature_c": {
            "type": "number",
            "description": "Water temperature in degrees Celsius."
          }
        }
      },
      "StationPage": {
        "type": "object",
        "required": [
          "data",
          "next_cursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Station"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cursor for the next page, or null on the last page."
          }
        }
      },
      "ObservationPage": {
        "type": "object",
        "required": [
          "data",
          "next_cursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Observation"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cursor for the next page, or null on the last page."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
