{
  "openapi": "3.1.1",
  "info": {
    "title": "Skyfold Sun Position and Shadow Length API",
    "version": "1.0.0",
    "summary": "Sun angle and the length and direction of a shadow for any height, place and time.",
    "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://skyfoldsunshadow.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Sun angle and the length and direction of a shadow for any height, place and time.",
        "description": "Computes the Sun’s azimuth and altitude, the length and compass direction of the shadow cast by an object of a given height on level ground, the shadow through the day, sunrise, solar noon, sunset and golden hour, plus a day-and-night map.\n\nMethodology:\n- Sun position from VSOP87 with nutation and aberration (Meeus chapter 25), topocentric for the place, with standard refraction for 10 °C and 1010 hPa.\n- Shadow length = height ÷ tan(altitude) on level ground; the shadow points away from the Sun (azimuth + 180°). Below 0.5° altitude the shadow is treated as unbounded.\n- Day-and-night map: sub-solar point from the apparent Sun and sidereal time; boundaries where the Sun is at −0.83°, −6°, −12° and −18°.\n\nAssumes flat, level ground and a thin vertical object; terrain, slopes, neighbouring buildings and atmospheric conditions change real shadows.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "skyfold_sun_shadow",
        "x-owner-app": "skyfold",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SkyfoldSunShadowInput"
              },
              "examples": {
                "example1": {
                  "summary": "A 6 m tree in Munich at the March equinox",
                  "value": {
                    "location": "48.1351, 11.582",
                    "elevation": 520,
                    "timeZone": "Europe/Berlin",
                    "date": "2026-03-20",
                    "time": "16:00",
                    "height": 6,
                    "unit": "m",
                    "stepMinutes": "60"
                  }
                },
                "example2": {
                  "summary": "A 30 ft house in Phoenix at the winter solstice",
                  "value": {
                    "location": "33.4484, -112.074",
                    "elevation": 331,
                    "timeZone": "America/Phoenix",
                    "date": "2026-12-21",
                    "time": "12:00",
                    "height": 30,
                    "unit": "ft",
                    "stepMinutes": "30"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkyfoldSunShadowResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "SkyfoldSunShadowInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "location": {
            "title": "Location (latitude, longitude)",
            "description": "Decimal degrees such as 52.09, 5.12 (north and east positive), or DMS, UTM, MGRS, Maidenhead or a plus code.",
            "type": "string",
            "maxLength": 80,
            "default": "48.1351, 11.582"
          },
          "elevation": {
            "title": "Elevation above sea level",
            "type": "number",
            "minimum": -500,
            "maximum": 9000,
            "default": 0,
            "x-unit": "m"
          },
          "timeZone": {
            "title": "Time zone",
            "description": "IANA name such as Europe/Berlin or America/New_York, or a fixed offset such as UTC+2.",
            "type": "string",
            "maxLength": 64,
            "default": "Europe/Berlin"
          },
          "date": {
            "title": "Local date",
            "type": "string",
            "format": "date",
            "default": "2026-03-20"
          },
          "time": {
            "title": "Local time",
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
            "default": "16:00"
          },
          "height": {
            "title": "Object height",
            "type": "number",
            "minimum": 0.01,
            "maximum": 1000,
            "default": 6
          },
          "unit": {
            "title": "Unit",
            "type": "string",
            "enum": [
              "m",
              "ft"
            ],
            "default": "m"
          },
          "stepMinutes": {
            "title": "Table step",
            "type": "string",
            "enum": [
              "15",
              "30",
              "60"
            ],
            "default": "60"
          }
        },
        "required": []
      },
      "SkyfoldSunShadowResult": {
        "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"
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}