{
  "openapi": "3.1.0",
  "info": {
    "title": "Tailwind KOMpass Public API",
    "version": "1.1.0",
    "summary": "Free, keyless, read-only endpoints for wind-on-segment calculations and plan information.",
    "description": "Tailwind KOMpass helps cyclists find Strava segments with a favourable wind so they can set PRs, KOMs and QOMs. This public API exposes the same signed-tailwind formula the app uses to score segments, a bearing helper, and the current Free/Pro plan facts. It needs no API key, is read-only (GET only), and returns JSON. Errors use RFC 9457 problem details (`application/problem+json`) with a machine-readable `code` and a `hint`. Personal data (watchlists, alerts, Strava activities) is not available through this API; use the web app at https://tailwindkompass.com for that. Agent guidance: https://tailwindkompass.com/llms.txt",
    "contact": {
      "name": "Tailwind KOMpass support",
      "email": "support@tailwindkompass.com",
      "url": "https://tailwindkompass.com/contact"
    },
    "termsOfService": "https://tailwindkompass.com/terms"
  },
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://tailwindkompass.com/developers"
  },
  "servers": [
    {
      "url": "https://api.tailwindkompass.com/functions/v1/public-api",
      "description": "Production"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "wind",
      "description": "Wind-on-segment calculations."
    },
    {
      "name": "product",
      "description": "Product and plan information."
    },
    {
      "name": "meta",
      "description": "Service metadata."
    }
  ],
  "paths": {
    "/v1/tailwind": {
      "get": {
        "operationId": "calculateTailwind",
        "tags": [
          "wind"
        ],
        "summary": "Signed tailwind along a segment",
        "description": "Returns the effective tailwind (positive) or headwind (negative) in km/h that a given wind produces along a segment, plus the crosswind component. This is the formula Tailwind KOMpass uses to rank segments: `signed = windSpeed * cos(windTowards - segmentBearing)`, where `windTowards = windDirection + 180`. Uses the raw 10 m meteorological wind, with no terrain shielding. Give the segment direction either as `segment_bearing_deg` or as start/end coordinates (all four of `start_lat`, `start_lon`, `end_lat`, `end_lon`).",
        "parameters": [
          {
            "name": "wind_speed_kmh",
            "in": "query",
            "required": true,
            "description": "Wind speed in km/h (10 m meteorological wind).",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 300
            },
            "example": 20
          },
          {
            "name": "wind_direction_deg",
            "in": "query",
            "required": true,
            "description": "Meteorological wind direction in degrees: where the wind comes FROM (0 = north, 90 = east).",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 360,
              "description": "Direction the wind blows from."
            },
            "example": 270
          },
          {
            "name": "segment_bearing_deg",
            "in": "query",
            "required": false,
            "description": "Direction of travel along the segment in degrees (0 = north, 90 = east). Required unless all four coordinates are given.",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 360,
              "description": "Direction of travel."
            },
            "example": 90
          },
          {
            "name": "start_lat",
            "in": "query",
            "required": false,
            "description": "Segment start latitude.",
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90,
              "description": "Start latitude."
            }
          },
          {
            "name": "start_lon",
            "in": "query",
            "required": false,
            "description": "Segment start longitude.",
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180,
              "description": "Start longitude."
            }
          },
          {
            "name": "end_lat",
            "in": "query",
            "required": false,
            "description": "Segment end latitude.",
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90,
              "description": "End latitude."
            }
          },
          {
            "name": "end_lon",
            "in": "query",
            "required": false,
            "description": "Segment end longitude.",
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180,
              "description": "End longitude."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The wind decomposed along the segment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TailwindResult"
                },
                "example": {
                  "signed_tailwind_kmh": 20,
                  "crosswind_kmh": 0,
                  "effect": "tailwind",
                  "segment_bearing_deg": 90,
                  "wind_speed_kmh": 20,
                  "wind_direction_deg": 270,
                  "formula": "signed = wind_speed_kmh * cos((wind_direction_deg + 180) - segment_bearing_deg)"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is missing or out of range.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected server error (code `internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bearing": {
      "get": {
        "operationId": "calculateBearing",
        "tags": [
          "wind"
        ],
        "summary": "Initial bearing between two points",
        "description": "Returns the initial great-circle bearing in degrees (0 = north, 90 = east) from a start point to an end point. Use it to get a `segment_bearing_deg` from a segment's start and end coordinates.",
        "parameters": [
          {
            "name": "start_lat",
            "in": "query",
            "required": true,
            "description": "Start latitude.",
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90,
              "description": "Start latitude."
            },
            "example": 52.37
          },
          {
            "name": "start_lon",
            "in": "query",
            "required": true,
            "description": "Start longitude.",
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180,
              "description": "Start longitude."
            },
            "example": 4.89
          },
          {
            "name": "end_lat",
            "in": "query",
            "required": true,
            "description": "End latitude.",
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90,
              "description": "End latitude."
            },
            "example": 52.37
          },
          {
            "name": "end_lon",
            "in": "query",
            "required": true,
            "description": "End longitude.",
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180,
              "description": "End longitude."
            },
            "example": 4.95
          }
        ],
        "responses": {
          "200": {
            "description": "The bearing from start to end.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BearingResult"
                },
                "example": {
                  "bearing_deg": 89.98,
                  "compass": "E"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is missing or out of range, or start and end are the same point.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected server error (code `internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/plans": {
      "get": {
        "operationId": "listPlans",
        "tags": [
          "product"
        ],
        "summary": "Free and Pro plan facts",
        "description": "Returns what Free and the three Pro plans (monthly, annual, lifetime) include, their prices and the free trial terms.",
        "responses": {
          "200": {
            "description": "The available plans.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlansResult"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected server error (code `internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getHealth",
        "tags": [
          "meta"
        ],
        "summary": "Service health",
        "description": "Returns `{\"status\":\"ok\"}` when the API is serving requests.",
        "responses": {
          "200": {
            "description": "The API is up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected server error (code `internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "tags": [
          "meta"
        ],
        "summary": "This OpenAPI document",
        "description": "Returns this OpenAPI 3.1 description of the API.",
        "responses": {
          "200": {
            "description": "The OpenAPI document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected server error (code `internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "TailwindResult": {
        "type": "object",
        "required": [
          "signed_tailwind_kmh",
          "crosswind_kmh",
          "effect",
          "segment_bearing_deg",
          "wind_speed_kmh",
          "wind_direction_deg",
          "formula"
        ],
        "properties": {
          "signed_tailwind_kmh": {
            "type": "number",
            "description": "Wind component along the direction of travel, rounded to 0.1 km/h. Positive = tailwind, negative = headwind."
          },
          "crosswind_kmh": {
            "type": "number",
            "description": "Magnitude of the wind component across the direction of travel, rounded to 0.1 km/h."
          },
          "effect": {
            "type": "string",
            "enum": [
              "tailwind",
              "headwind",
              "crosswind",
              "calm"
            ],
            "description": "`calm` when there is no wind; `crosswind` when the along-track component is under 1 km/h."
          },
          "segment_bearing_deg": {
            "type": "number",
            "description": "The bearing used, in degrees (computed from coordinates when given)."
          },
          "wind_speed_kmh": {
            "type": "number",
            "description": "Echo of the input wind speed."
          },
          "wind_direction_deg": {
            "type": "number",
            "description": "Echo of the input wind direction."
          },
          "formula": {
            "type": "string",
            "description": "The formula applied."
          }
        }
      },
      "BearingResult": {
        "type": "object",
        "required": [
          "bearing_deg",
          "compass"
        ],
        "properties": {
          "bearing_deg": {
            "type": "number",
            "description": "Initial bearing in degrees [0, 360), rounded to 0.01."
          },
          "compass": {
            "type": "string",
            "enum": [
              "N",
              "NE",
              "E",
              "SE",
              "S",
              "SW",
              "W",
              "NW"
            ],
            "description": "Eight-point compass direction of the bearing."
          }
        }
      },
      "Plan": {
        "type": "object",
        "required": [
          "id",
          "name",
          "price",
          "billing",
          "features"
        ],
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "free",
              "pro_monthly",
              "pro_annual",
              "pro_lifetime"
            ]
          },
          "name": {
            "type": "string"
          },
          "price": {
            "type": "object",
            "required": [
              "eur",
              "usd"
            ],
            "properties": {
              "eur": {
                "type": "string"
              },
              "usd": {
                "type": "string"
              }
            },
            "description": "Display prices. Free is \"€0\" / \"$0\"."
          },
          "list_price": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "eur": {
                "type": "string"
              },
              "usd": {
                "type": "string"
              }
            },
            "description": "Always null: no plan is discounted. Kept so 1.0 clients keep parsing."
          },
          "billing": {
            "type": "string",
            "enum": [
              "free",
              "monthly",
              "yearly",
              "one-time"
            ]
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "PlansResult": {
        "type": "object",
        "required": [
          "plans",
          "trial",
          "pricing_url"
        ],
        "properties": {
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Plan"
            }
          },
          "trial": {
            "type": "object",
            "required": [
              "days",
              "how_to_start"
            ],
            "properties": {
              "days": {
                "type": "integer",
                "description": "Length of the free Pro trial in days."
              },
              "how_to_start": {
                "type": "string"
              }
            }
          },
          "pricing_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "status",
          "version"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "version": {
            "type": "string"
          }
        }
      },
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details, extended with `code` and `hint`.",
        "required": [
          "type",
          "title",
          "status",
          "detail",
          "code",
          "hint"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "URI identifying the problem type."
          },
          "title": {
            "type": "string",
            "description": "Short, human-readable summary of the problem type."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code."
          },
          "detail": {
            "type": "string",
            "description": "Explanation specific to this occurrence."
          },
          "instance": {
            "type": "string",
            "description": "The request path that produced the problem."
          },
          "code": {
            "type": "string",
            "enum": [
              "not_found",
              "method_not_allowed",
              "invalid_parameter",
              "missing_parameter",
              "internal_error"
            ],
            "description": "Stable machine-readable error code."
          },
          "hint": {
            "type": "string",
            "description": "How to resolve the problem."
          },
          "parameter": {
            "type": "string",
            "description": "The offending query parameter, for parameter errors."
          }
        }
      }
    }
  }
}
