{
  "openapi": "3.1.1",
  "info": {
    "title": "Quiet Week Finder API",
    "version": "1.0.0",
    "summary": "Find the weeks when the main visitor countries of a destination are not on holiday.",
    "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://hearthquietweeks.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Find the weeks when the main visitor countries of a destination are not on holiday.",
        "description": "Name the countries most visitors to a place come from, with weights, and get a crowd index for every week: how much of each country is on school or public holiday. The lowest weeks are the quiet ones for a trip, a booking or an errand.\n\nMethodology:\n- Loads the school holidays and public holidays of every visitor country for the period from the OpenHolidays API (cached for a week).\n- For each country and day, the holiday share is 1 for a nationwide holiday, otherwise the share of the country’s regions (top-level subdivisions that appear in its holiday data) that are off school or on a public holiday that day.\n- The crowd index of a week (Monday–Sunday) is the weighted average of these daily shares over the seven days and the visitor countries: 0 = nobody is on holiday, 100 = every visitor country is fully on holiday all week.\n- Quiet weeks are the five lowest; quiet stretches are runs of consecutive weeks at or below 10.\n\nRegions are counted equally, not by population, and holidays only stand in for crowds: events, weather and local festivals matter too.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "hearth_quiet_weeks",
        "x-owner-app": "hearth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HearthQuietWeeksInput"
              },
              "examples": {
                "example1": {
                  "summary": "Dutch coast: Germans, Dutch and Belgians, 2027",
                  "value": {
                    "visitors": "DE:3, NL:2, BE:1",
                    "from": "2027-01-04",
                    "to": "2027-12-27"
                  }
                },
                "example2": {
                  "summary": "Lake Garda: Germans, Austrians, Italians, summer 2027",
                  "value": {
                    "visitors": "DE:3, AT:1, IT:2",
                    "from": "2027-05-03",
                    "to": "2027-09-27"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HearthQuietWeeksResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "HearthQuietWeeksInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "visitors": {
            "title": "Visitor countries with weights",
            "description": "Two-letter codes, optional weights, for example “DE:3, NL:2, BE:1”. Include the destination’s own country for local visitors.",
            "type": "string",
            "maxLength": 200,
            "default": "DE:3, NL:2, BE:1"
          },
          "from": {
            "title": "Period from",
            "type": "string",
            "format": "date",
            "default": "2027-01-04"
          },
          "to": {
            "title": "Period to",
            "type": "string",
            "format": "date",
            "default": "2027-12-27"
          }
        },
        "required": [
          "visitors",
          "from",
          "to"
        ]
      },
      "HearthQuietWeeksResult": {
        "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": [
              "visitors",
              "weeks",
              "quietest",
              "busiest",
              "quietRuns",
              "averageIndex",
              "attribution"
            ],
            "properties": {
              "visitors": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "weight"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "weight": {
                      "type": "number"
                    }
                  }
                }
              },
              "weeks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "week",
                    "end",
                    "index",
                    "countries",
                    "holidays"
                  ],
                  "properties": {
                    "week": {
                      "type": "string"
                    },
                    "end": {
                      "type": "string"
                    },
                    "index": {
                      "type": "number"
                    },
                    "countries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "code",
                          "holidayShare",
                          "schoolShare",
                          "publicShare"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "holidayShare": {
                            "type": "number"
                          },
                          "schoolShare": {
                            "type": "number"
                          },
                          "publicShare": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "holidays": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "quietest": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "busiest": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "quietRuns": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "from",
                    "to",
                    "weeks"
                  ],
                  "properties": {
                    "from": {
                      "type": "string"
                    },
                    "to": {
                      "type": "string"
                    },
                    "weeks": {
                      "type": "integer"
                    }
                  }
                }
              },
              "averageIndex": {
                "type": "number"
              },
              "attribution": {
                "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"
              }
            }
          }
        }
      }
    }
  }
}