{
  "openapi": "3.1.1",
  "info": {
    "title": "Sun Windows API",
    "version": "1.0.0",
    "summary": "Find approximate direct-sun windows from your location and measured obstacles.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://hearthsunwindows.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Find approximate direct-sun windows from your location and measured obstacles.",
        "description": "Explore direct-sun windows, an optional window facing direction and a monthly comparison from your location and measured obstacle angles.\n\nMethodology:\n- NOAA fractional-year solar position equations with 1, 5 or 15 minute midpoint sampling. Supply the UTC offset including daylight saving for the selected date.\n- Obstacles are angular sectors with elevation atan(height/distance). Facing restricts light to the front half-plane of a vertical window. No weather, terrain or building download, refraction or PV-yield model.\n- Monthly comparison uses the 21st of each month at 15-minute resolution and the same fixed UTC offset; it is a geometric comparison, not a local-clock daylight-saving calendar.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "hearth_sun_windows",
        "x-owner-app": "hearth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HearthSunWindowsInput"
              },
              "examples": {
                "example1": {
                  "summary": "Try an example",
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HearthSunWindowsResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "HearthSunWindowsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "day": {
            "title": "Date",
            "type": "string",
            "format": "date",
            "default": "2026-06-21"
          },
          "latitude": {
            "title": "Latitude",
            "type": "number",
            "minimum": -89.9,
            "maximum": 89.9,
            "default": 48.89
          },
          "longitude": {
            "title": "Longitude",
            "type": "number",
            "minimum": -180,
            "maximum": 180,
            "default": 8.7
          },
          "utcOffset": {
            "title": "UTC offset on selected date",
            "type": "number",
            "minimum": -12,
            "maximum": 14,
            "default": 2
          },
          "facing": {
            "title": "Window facing (degrees, -1 = open sky)",
            "type": "number",
            "minimum": -1,
            "maximum": 360,
            "default": -1
          },
          "stepMinutes": {
            "title": "Sampling interval (minutes)",
            "type": "string",
            "enum": [
              "5",
              "1",
              "15"
            ],
            "default": "5"
          },
          "obstacles": {
            "title": "Obstacles from the observation point",
            "type": "array",
            "maxItems": 30,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "azimuth": {
                  "title": "Bearing from north (degrees)",
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000
                },
                "width": {
                  "title": "Angular width (degrees)",
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000
                },
                "height": {
                  "title": "Height above observation point (m)",
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000
                },
                "distance": {
                  "title": "Horizontal distance (m)",
                  "type": "number",
                  "minimum": -1000000000,
                  "maximum": 1000000000
                }
              },
              "required": [
                "azimuth",
                "width",
                "height",
                "distance"
              ]
            },
            "default": [
              {
                "azimuth": 180,
                "width": 40,
                "height": 5,
                "distance": 10
              }
            ]
          }
        },
        "required": []
      },
      "HearthSunWindowsResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "sunHours",
              "windows",
              "samples",
              "seasons",
              "daylightHours",
              "maxAltitude",
              "solarNoon",
              "resolutionMinutes",
              "svg"
            ],
            "properties": {
              "sunHours": {
                "type": "number"
              },
              "windows": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "start",
                    "end",
                    "startLabel",
                    "endLabel"
                  ],
                  "properties": {
                    "start": {
                      "type": "number"
                    },
                    "end": {
                      "type": "number"
                    },
                    "startLabel": {
                      "type": "string"
                    },
                    "endLabel": {
                      "type": "string"
                    }
                  }
                }
              },
              "samples": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "hour",
                    "altitude",
                    "azimuth",
                    "sunlit"
                  ],
                  "properties": {
                    "hour": {
                      "type": "number"
                    },
                    "altitude": {
                      "type": "number"
                    },
                    "azimuth": {
                      "type": "number"
                    },
                    "sunlit": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "seasons": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "month",
                    "day",
                    "sunHours"
                  ],
                  "properties": {
                    "month": {
                      "type": "number"
                    },
                    "day": {
                      "type": "string"
                    },
                    "sunHours": {
                      "type": "number"
                    }
                  }
                }
              },
              "daylightHours": {
                "type": "number"
              },
              "maxAltitude": {
                "type": "number"
              },
              "solarNoon": {
                "type": "string"
              },
              "resolutionMinutes": {
                "type": "number"
              },
              "svg": {
                "type": "string"
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}