{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/openwaters-io/json-schema/openwaters-io-current-station-schema.json",
  "title": "CurrentStation",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/openwaters-io-openapi.json#/components/schemas/CurrentStation",
  "allOf": [
    {
      "$ref": "#/$defs/Station"
    },
    {
      "$ref": "#/$defs/CurrentAvailability"
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "current"
          ]
        },
        "current": {
          "type": "object",
          "properties": {
            "flood_direction": {
              "type": "number",
              "description": "Degrees true"
            },
            "ebb_direction": {
              "type": "number",
              "description": "Degrees true"
            },
            "mean_flow": {
              "type": "number",
              "description": "Knots"
            },
            "minor_constituents": {
              "type": "array",
              "description": "Minor-axis amplitudes in knots and phases in degrees",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "amplitude": {
                    "type": "number"
                  },
                  "phase": {
                    "type": "number"
                  }
                }
              }
            },
            "minor_mean_flow": {
              "type": "number",
              "description": "Minor-axis mean flow in knots"
            },
            "azimuth": {
              "type": "number",
              "description": "Major-axis azimuth in degrees true"
            },
            "offsets": {
              "type": "object",
              "description": "Subordinate stations only. Times in minutes, ratios dimensionless.",
              "properties": {
                "reference": {
                  "type": "string"
                },
                "slack_before_flood": {
                  "type": "number"
                },
                "slack_before_ebb": {
                  "type": "number"
                },
                "flood_time": {
                  "type": "number"
                },
                "ebb_time": {
                  "type": "number"
                },
                "flood_speed_ratio": {
                  "type": "number"
                },
                "ebb_speed_ratio": {
                  "type": "number"
                }
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "CurrentAvailability": {
      "type": "object",
      "properties": {
        "bins": {
          "type": "array",
          "description": "Every depth bin of this station, primary first",
          "items": {
            "$ref": "#/$defs/CurrentBin"
          }
        },
        "predictions": {
          "type": "boolean",
          "description": "Whether this API can serve predictions for the station"
        },
        "unavailable": {
          "type": "string",
          "description": "Why predictions can't be served, when `predictions` is false"
        }
      },
      "required": [
        "bins",
        "predictions"
      ]
    },
    "CurrentBin": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Station ID for this bin"
        },
        "bin": {
          "type": "integer",
          "description": "Bin number; absent for the primary bin, which the bare station ID selects"
        }
      },
      "required": [
        "id"
      ]
    },
    "Station": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "latitude": {
          "type": "number"
        },
        "longitude": {
          "type": "number"
        },
        "region": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "continent": {
          "type": "string"
        },
        "timezone": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "reference",
            "subordinate"
          ]
        },
        "source": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "url": {
              "type": "string"
            }
          }
        },
        "license": {
          "$ref": "#/$defs/StationLicense"
        },
        "attribution": {
          "$ref": "#/$defs/StationAttribution"
        },
        "disclaimers": {
          "type": "string"
        },
        "distance": {
          "type": "number",
          "description": "Distance from query point in kilometers (only for proximity searches)"
        },
        "datums": {
          "type": "object",
          "properties": {
            "CD": {
              "type": "number"
            },
            "CRD_OFFSET": {
              "type": "number"
            },
            "DHQ": {
              "type": "number"
            },
            "DLQ": {
              "type": "number"
            },
            "DTL": {
              "type": "number"
            },
            "GT": {
              "type": "number"
            },
            "GUVD04": {
              "type": "number"
            },
            "HAT": {
              "type": "number"
            },
            "HWI": {
              "type": "number"
            },
            "LAT": {
              "type": "number"
            },
            "LLWLT": {
              "type": "number"
            },
            "LWI": {
              "type": "number"
            },
            "MHHW": {
              "type": "number"
            },
            "MHW": {
              "type": "number"
            },
            "MHWN": {
              "type": "number"
            },
            "MHWS": {
              "type": "number"
            },
            "MLLW": {
              "type": "number"
            },
            "MLW": {
              "type": "number"
            },
            "MLWN": {
              "type": "number"
            },
            "MLWS": {
              "type": "number"
            },
            "MN": {
              "type": "number"
            },
            "MSL": {
              "type": "number"
            },
            "MTL": {
              "type": "number"
            },
            "NAVD88": {
              "type": "number"
            },
            "NLLW": {
              "type": "number"
            },
            "NMVD03": {
              "type": "number"
            },
            "NN2000": {
              "type": "number"
            },
            "PRVD02": {
              "type": "number"
            },
            "STND": {
              "type": "number"
            },
            "TLT": {
              "type": "number"
            },
            "VIVD09": {
              "type": "number"
            }
          },
          "additionalProperties": {
            "type": "number"
          }
        },
        "harmonic_constituents": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "amplitude": {
                "type": "number"
              },
              "phase": {
                "type": "number"
              }
            }
          }
        },
        "defaultDatum": {
          "type": "string"
        },
        "offsets": {
          "type": "object",
          "properties": {
            "reference": {
              "type": "string"
            },
            "height": {
              "type": "object",
              "properties": {
                "high": {
                  "type": "number"
                },
                "low": {
                  "type": "number"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "ratio",
                    "fixed"
                  ]
                }
              }
            },
            "time": {
              "type": "object",
              "properties": {
                "high": {
                  "type": "number"
                },
                "low": {
                  "type": "number"
                }
              }
            }
          }
        }
      }
    },
    "StationAttribution": {
      "type": "string",
      "description": "The credit to display wherever the station's data is shown"
    },
    "StationLicense": {
      "type": "object",
      "description": "The license of the station's data. Hosts must honor `commercial_use: false` (CC BY-NC stations).",
      "properties": {
        "type": {
          "type": "string"
        },
        "commercial_use": {
          "type": "boolean"
        },
        "url": {
          "type": "string"
        },
        "notes": {
          "type": "string"
        }
      }
    }
  }
}