{
  "openapi": "3.1.0",
  "info": {
    "title": "Taxi Bettmeralp Price API",
    "version": "1.0.0",
    "description": "Official read-only API for Aletsch Transporte taxi price lookup on Bettmeralp. Returns prices and booking links; it does not create bookings. Future write actions should require an action token and explicit guest confirmation."
  },
  "servers": [
    {
      "url": "https://www.taxialetsch.ch"
    }
  ],
  "paths": {
    "/ai/price.php": {
      "get": {
        "operationId": "lookupTaxiPriceOrSearchChalets",
        "summary": "Search chalets or retrieve a taxi fixed price",
        "description": "Rate limit: 90 requests per 60 seconds per client/action. This endpoint is read-only and returns official booking URLs.",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["search", "price"]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search text for chalet lookup. Required when action=search.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chalet",
            "in": "query",
            "required": false,
            "description": "Exact chalet name. Required when action=price.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Price or search result",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/SearchResponse"
                    },
                    {
                      "$ref": "#/components/schemas/PriceResponse"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SearchItem": {
        "type": "object",
        "properties": {
          "idhaus": {
            "type": ["integer", "null"]
          },
          "chalet": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "price_chf": {
            "type": ["number", "null"]
          },
          "booking_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "query": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "example": "CHF"
          },
          "price_note": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchItem"
            }
          }
        }
      },
      "PriceResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "chalet": {
            "type": "string"
          },
          "idhaus": {
            "type": ["integer", "null"]
          },
          "price_chf": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "example": "CHF"
          },
          "price_note": {
            "type": "string"
          },
          "booking_url": {
            "type": "string",
            "format": "uri"
          },
          "booking_policy": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "FutureActionToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Aletsch-Action-Token",
        "description": "Reserved for future booking/write actions. Not required for current read-only price lookup."
      }
    }
  }
}
