{
  "openapi": "3.0.3",
  "info": {
    "title": "Falling Tree Risk Assessment API",
    "description": "AI-powered REST API that predicts the probability of trees falling on a US property. Analyzes historical storm frequency, wind speed, precipitation records, and satellite tree coverage density to return an annual risk probability with confidence intervals.",
    "version": "1.0.0",
    "contact": {
      "name": "Cascadian Intelligence, Inc.",
      "url": "https://fallingtreerisk.com/contact",
      "email": "support@fallingtreerisk.com"
    },
    "license": {
      "name": "Commercial",
      "url": "https://fallingtreerisk.com/faq"
    },
    "x-logo": {
      "url": "https://fallingtreerisk.com/falling_tree_risk_logo.png"
    }
  },
  "externalDocs": {
    "description": "Full documentation and FAQ",
    "url": "https://fallingtreerisk.com/faq"
  },
  "servers": [
    {
      "url": "https://api.fallingtreerisk.com/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyQuery": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "api_key",
        "description": "API key obtained from https://fallingtreerisk.com/account. Free tier: 20 requests/month."
      }
    },
    "schemas": {
      "RiskAssessment": {
        "type": "object",
        "required": [
          "risk_level",
          "property_risk_annual",
          "property_risk_annual_low",
          "property_risk_annual_high",
          "num_storms_2_years",
          "max_wind_speed_kmh",
          "max_precipitation_24h_mm"
        ],
        "properties": {
          "risk_level": {
            "type": "string",
            "enum": ["Very Low", "Low", "Medium", "High", "Very High"],
            "description": "Categorical risk level based on annual probability. Thresholds: Very Low <0.1%, Low 0.1-0.5%, Medium 0.5-1%, High 1-2%, Very High >=2%.",
            "example": "Low"
          },
          "property_risk_annual": {
            "type": "number",
            "format": "float",
            "description": "Annual probability of a tree falling on the property, expressed as a decimal (e.g. 0.0031 = 0.31%).",
            "example": 0.0031,
            "minimum": 0,
            "maximum": 1
          },
          "property_risk_annual_low": {
            "type": "number",
            "format": "float",
            "description": "Lower bound of the 90% confidence interval for the annual probability.",
            "example": 0.0018,
            "minimum": 0,
            "maximum": 1
          },
          "property_risk_annual_high": {
            "type": "number",
            "format": "float",
            "description": "Upper bound of the 90% confidence interval for the annual probability.",
            "example": 0.0052,
            "minimum": 0,
            "maximum": 1
          },
          "num_storms_2_years": {
            "type": "integer",
            "description": "Number of significant storms recorded near the property in the past 2 years.",
            "example": 4,
            "minimum": 0
          },
          "max_wind_speed_kmh": {
            "type": "number",
            "format": "float",
            "description": "Maximum historical wind speed recorded near the property, in km/h.",
            "example": 87.3,
            "minimum": 0
          },
          "max_precipitation_24h_mm": {
            "type": "number",
            "format": "float",
            "description": "Maximum historical 24-hour precipitation recorded near the property, in mm.",
            "example": 62.1,
            "minimum": 0
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error message.",
            "example": "Invalid or missing api_key"
          }
        }
      }
    }
  },
  "paths": {
    "/getFallingTreeRisk": {
      "get": {
        "operationId": "getFallingTreeRisk",
        "summary": "Get falling tree risk assessment for a US property",
        "description": "Returns a complete falling tree risk assessment for the given US property address. The assessment is based on satellite tree coverage density, historical storm frequency, wind speed records, and precipitation data. Coverage: all 50 US states and territories.",
        "tags": ["Risk Assessment"],
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "required": true,
            "description": "Full US property address including street, city, state, and zip code.",
            "schema": {
              "type": "string",
              "example": "123 Main St, Portland, OR 97201"
            }
          },
          {
            "name": "api_key",
            "in": "query",
            "required": true,
            "description": "Your API key. Get one free at https://fallingtreerisk.com/account.",
            "schema": {
              "type": "string",
              "example": "ftrs_abc123xyz"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful risk assessment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskAssessment"
                },
                "example": {
                  "risk_level": "Low",
                  "property_risk_annual": 0.0031,
                  "property_risk_annual_low": 0.0018,
                  "property_risk_annual_high": 0.0052,
                  "num_storms_2_years": 4,
                  "max_wind_speed_kmh": 87.3,
                  "max_precipitation_24h_mm": 62.1
                }
              }
            }
          },
          "400": {
            "description": "Bad request — missing or invalid address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded — monthly quota reached. Upgrade at https://fallingtreerisk.com/pricing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  }
}
