{
  "openapi": "3.1.0",
  "info": {
    "title": "tides.watch Tide API",
    "version": "1.0.0",
    "description": "Tide predictions (high and low tides, and the tide curve) for any coast, from official and open sources: NOAA, the Marine Institute (Ireland), LINZ (New Zealand), Maritime Safety Queensland, and TICON-4 tide gauge constants, with an opt-in global model (FES2022). Every answer names its source, station and distance, and carries the attribution text to show. Not for navigation.",
    "contact": {
      "name": "tides.watch",
      "url": "https://tides.watch/api/",
      "email": "palmerboop@gmail.com"
    },
    "termsOfService": "https://tides.watch/api/terms/"
  },
  "servers": [
    {
      "url": "https://api.tides.watch"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "externalDocs": {
    "description": "Docs, plans and free developer keys",
    "url": "https://tides.watch/api/"
  },
  "paths": {
    "/v1/tides": {
      "get": {
        "operationId": "getTides",
        "summary": "High and low tides near a point",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "description": "Latitude, -90 to 90.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "lon",
            "in": "query",
            "required": true,
            "description": "Longitude, -180 to 180.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "How many days, 1-7. Default 2.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 7,
              "default": 2
            }
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "description": "Start: a date (2026-12-01), date-time or unix seconds. Default: now.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "max_km",
            "in": "query",
            "required": false,
            "description": "How far to look for a tide station, 1-50 km. Default 10.",
            "schema": {
              "type": "number",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          },
          {
            "name": "units",
            "in": "query",
            "required": false,
            "description": "Heights in metres or feet.",
            "schema": {
              "type": "string",
              "enum": [
                "m",
                "ft"
              ],
              "default": "m"
            }
          },
          {
            "name": "blend",
            "in": "query",
            "required": false,
            "description": "false = single stations only (no two-gauge blend).",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "true"
            }
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "description": "true = where there's no tide station within max_km, answer from the FES2022 global ocean tide model (checked at 80 tide gauges: typically ~8 min from the measured tide; less accurate in bays and estuaries). Off by default.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "High and low tides",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tides"
                }
              }
            }
          },
          "400": {
            "description": "Bad input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No tide station (or model point, with model=true) in range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (free keys: 100 a day)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The station's data source didn't answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/heights": {
      "get": {
        "operationId": "getHeights",
        "summary": "The tide curve: heights at regular times",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "description": "Latitude, -90 to 90.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "lon",
            "in": "query",
            "required": true,
            "description": "Longitude, -180 to 180.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "hours",
            "in": "query",
            "required": false,
            "description": "How many hours, 1-168. Default 24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 168,
              "default": 24
            }
          },
          {
            "name": "step",
            "in": "query",
            "required": false,
            "description": "Minutes between heights, 5-60. Default 10.",
            "schema": {
              "type": "integer",
              "minimum": 5,
              "maximum": 60,
              "default": 10
            }
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "description": "Start: a date (2026-12-01), date-time or unix seconds. Default: now.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "max_km",
            "in": "query",
            "required": false,
            "description": "How far to look for a tide station, 1-50 km. Default 10.",
            "schema": {
              "type": "number",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          },
          {
            "name": "units",
            "in": "query",
            "required": false,
            "description": "Heights in metres or feet.",
            "schema": {
              "type": "string",
              "enum": [
                "m",
                "ft"
              ],
              "default": "m"
            }
          },
          {
            "name": "blend",
            "in": "query",
            "required": false,
            "description": "false = single stations only (no two-gauge blend).",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "true"
            }
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "description": "true = where there's no tide station within max_km, answer from the FES2022 global ocean tide model (checked at 80 tide gauges: typically ~8 min from the measured tide; less accurate in bays and estuaries). Off by default.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tide heights",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Heights"
                }
              }
            }
          },
          "400": {
            "description": "Bad input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No tide station (or model point, with model=true) in range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (free keys: 100 a day)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The station's data source didn't answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/stations": {
      "get": {
        "operationId": "getStations",
        "summary": "Tide stations near a point, nearest first",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "description": "Latitude, -90 to 90.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "lon",
            "in": "query",
            "required": true,
            "description": "Longitude, -180 to 180.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "radius_km",
            "in": "query",
            "required": false,
            "description": "Search radius, 1-200 km. Default 25.",
            "schema": {
              "type": "number",
              "minimum": 1,
              "maximum": 200,
              "default": 25
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many, 1-100. Default 20.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Stations"
                }
              }
            }
          },
          "400": {
            "description": "Bad input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or unknown API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No tide station (or model point, with model=true) in range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (free keys: 100 a day)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The station's data source didn't answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Your key (free developer keys are instant at https://tides.watch/api/). ?key= also works."
      }
    },
    "schemas": {
      "Station": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "examples": [
              "NOAA",
              "Marine Institute",
              "LINZ",
              "Queensland",
              "TICON-4",
              "FES2022",
              "EOT20"
            ]
          },
          "type": {
            "type": "string",
            "examples": [
              "tide station",
              "tide gauge",
              "subordinate station",
              "secondary port",
              "two-gauge blend",
              "global tide model"
            ]
          },
          "lat": {
            "type": "number"
          },
          "lon": {
            "type": "number"
          },
          "distance_km": {
            "type": "number"
          },
          "between": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "note": {
            "type": "string"
          }
        }
      },
      "Common": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer"
          },
          "location": {
            "type": "object",
            "properties": {
              "lat": {
                "type": "number"
              },
              "lon": {
                "type": "number"
              }
            }
          },
          "station": {
            "$ref": "#/components/schemas/Station"
          },
          "datum": {
            "type": "string",
            "examples": [
              "LAT (Lowest Astronomical Tide)",
              "MLLW (Mean Lower Low Water)",
              "MSL (mean sea level)"
            ]
          },
          "units": {
            "type": "string"
          },
          "attribution": {
            "type": "string",
            "description": "Show this wherever you show the predictions."
          },
          "disclaimer": {
            "type": "string"
          },
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Tides": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Common"
          },
          {
            "type": "object",
            "properties": {
              "extremes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "time": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "unix": {
                      "type": "integer"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "high",
                        "low"
                      ]
                    },
                    "height": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "Heights": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Common"
          },
          {
            "type": "object",
            "properties": {
              "step_minutes": {
                "type": "integer"
              },
              "heights": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "time": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "unix": {
                      "type": "integer"
                    },
                    "height": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "Stations": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "stations": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Station"
                },
                {
                  "type": "object",
                  "properties": {
                    "heights_available": {
                      "type": "boolean"
                    },
                    "attribution": {
                      "type": "string"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer"
          },
          "error": {
            "type": "string"
          },
          "docs": {
            "type": "string"
          }
        }
      }
    }
  }
}