openapi: 3.1.0
info:
  title: Chosen Flight public flight API (read-only subset)
  version: 0.1.0-local
  summary: Endpoints used by the server-rendered site (site/) and the MCP AI connector (mcp_server/).
  description: |
    LOCAL ONLY (26.10.2026). Nothing here is published; the server URL is a local placeholder.

    Rules that every client must respect:
    - Stage 1-2: while FLYIL_SHOW_OWN_PRICES is not "1" the API returns NO prices (`own_prices: false`,
      empty `itineraries`) and calls no flight provider. Clients show only partner buttons (`visible: true`),
      the White Label state and the affiliate disclosure.
    - Freshness: a price whose `checked_at` is more than 300 seconds old, in the future, or without a
      timezone must not be shown. Every shown price carries its source (`sources`) and `checked_at`.
    - `total_amount` is the full price for all passengers (decimal string, never converted between currencies).
    - Partner links use rel="sponsored noopener"; no partner button shows a price.
    - Every route must start or end at an Israeli airport (TLV, ETM, HFA).
servers:
  - url: https://api.chosenflight.com
    description: Production API
paths:
  /api/health:
    get:
      operationId: health
      summary: Liveness check
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok: {type: boolean}
                  time: {type: string, format: date-time}
  /api/status:
    get:
      operationId: status
      summary: Data mode, providers, stage, partners, disclaimers
      responses:
        '200':
          description: Status
          content:
            application/json:
              schema:
                type: object
                properties:
                  data_mode: {type: string, enum: [live, none]}
                  show_own_prices: {type: boolean}
                  stage: {type: integer}
                  israeli_airports: {type: array, items: {type: string}}
                  partners: {type: array, items: {$ref: '#/components/schemas/Partner'}}
                  white_label: {$ref: '#/components/schemas/WhiteLabel'}
                  disclaimer_he: {type: string}
                  disclaimer_en: {type: string}
                  affiliate_disclosure_he: {type: string}
                  affiliate_disclosure_en: {type: string}
  /api/partners:
    get:
      operationId: partnerLinks
      summary: Partner buttons and White Label state for a search (never a price)
      description: A partner is `visible` and has a `url` only when affiliate links are enabled, its affiliate ID and URL template are configured, and origin, destination and depart are given.
      parameters:
        - {name: origin, in: query, schema: {$ref: '#/components/schemas/IATA'}}
        - {name: destination, in: query, schema: {$ref: '#/components/schemas/IATA'}}
        - {name: depart, in: query, schema: {type: string, format: date}}
        - {name: ret, in: query, description: Return date, schema: {type: string, format: date}}
        - {name: adults, in: query, schema: {type: integer, minimum: 1, maximum: 9, default: 1}}
        - {name: children, in: query, schema: {type: integer, minimum: 0, maximum: 8, default: 0}}
        - {name: infants, in: query, schema: {type: integer, minimum: 0, default: 0}}
      responses:
        '200':
          description: Partner info
          content:
            application/json:
              schema: {$ref: '#/components/schemas/PartnerInfo'}
  /api/airports/suggest:
    get:
      operationId: suggestAirports
      summary: Airport autocomplete (OurAirports data)
      parameters:
        - {name: q, in: query, schema: {type: string}}
        - {name: lang, in: query, schema: {type: string, enum: [he, en, ru, ar], default: he}}
        - {name: limit, in: query, schema: {type: integer, minimum: 1, maximum: 20, default: 8}}
      responses:
        '200':
          description: Matching airports
          content:
            application/json:
              schema: {type: object}
  /api/search:
    post:
      operationId: searchFlights
      summary: Search flights to or from Israel
      description: With FLYIL_SHOW_OWN_PRICES off the request is only validated and the price-free response (`own_prices false`, partner info) is returned.
      requestBody:
        required: true
        content:
          application/json:
            schema: {$ref: '#/components/schemas/SearchRequest'}
      responses:
        '200':
          description: Search result (or the price-free stage 1 response)
          content:
            application/json:
              schema: {$ref: '#/components/schemas/SearchResponse'}
        '400': {description: Invalid request (for example a route that does not touch TLV/ETM/HFA)}
  /api/calendar:
    post:
      operationId: priceCalendar
      summary: Cheapest fresh price per day around a date (no prices while the flag is off)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/SearchRequest'
                - type: object
                  properties:
                    flex: {type: integer, minimum: 0, maximum: 3, default: 3, description: 'Days before and after depart (values above 3 are clamped to 3)'}
      responses:
        '200':
          description: Calendar
          content:
            application/json:
              schema: {type: object, properties: {own_prices: {type: boolean}, outbound: {type: array, items: {type: object}}}}
        '400': {description: Invalid request}
  /api/flight-map:
    get:
      operationId: flightMap
      summary: Delayed regional sightings for verified scheduled passenger flights
      description: Returns the complete regional snapshot under ODbL 1.0. Bounds are one-degree cells in west, south, east, north order. Each observation is at least 15 and less than 30 minutes old.
      responses:
        '200':
          description: State ok can include an empty list. State unavailable indicates a source or storage failure.
          headers:
            Link:
              description: Links to the observation source and ODbL license.
              schema: {type: string}
          content:
            application/json:
              schema:
                type: object
                required: [state, flights]
                properties:
                  state: {type: string, enum: [ok, unavailable]}
                  flights:
                    type: array
                    items:
                      type: object
                      required: [flight, scheduled_local, direction, other_iata, observed_at, bounds]
                      properties:
                        flight: {type: string, description: Scheduled passenger flight number}
                        scheduled_local: {type: string, description: Scheduled TLV event in Israel time}
                        direction: {type: string, enum: [arrival, departure]}
                        other_iata: {$ref: '#/components/schemas/IATA'}
                        observed_at: {type: string, format: date-time}
                        bounds: {type: array, minItems: 4, maxItems: 4, items: {type: integer}}
        '429':
          description: Client request limit reached
components:
  schemas:
    IATA: {type: string, pattern: '^[A-Za-z]{3}$'}
    SearchRequest:
      type: object
      required: [origin, destination, depart]
      properties:
        origin: {$ref: '#/components/schemas/IATA'}
        destination: {$ref: '#/components/schemas/IATA'}
        depart: {type: string, format: date}
        return: {type: string, format: date}
        trip: {type: string, enum: [roundtrip, oneway], default: roundtrip}
        adults: {type: integer, minimum: 1, maximum: 9, default: 1}
        children: {type: integer, minimum: 0, maximum: 8, default: 0}
        infants: {type: integer, minimum: 0, default: 0, description: At most the number of adults}
        cabin: {type: string, enum: [economy, premium_economy, business, first], default: economy}
        currency: {type: string, default: USD}
        israeli_only: {type: boolean, default: false}
        airlines: {type: array, items: {type: string}}
        max_connections: {type: integer, minimum: 0, default: 1, description: Connections per slice; offers with more are rejected}
    Itinerary:
      type: object
      properties:
        id: {type: string}
        kind: {type: string}
        total_amount: {type: string, description: Full price for all passengers, decimal string}
        currency: {type: string}
        carriers: {type: array, items: {type: string}}
        sources: {type: array, items: {type: string}}
        separate_tickets: {type: boolean}
        is_demo: {type: boolean}
        checked_at: {type: string, format: date-time, description: UTC time the price was received; not shown after 300 s}
        checked_at_il: {type: string, description: Same time in Israel time}
        tickets: {type: array, items: {type: object}}
    SearchResponse:
      type: object
      properties:
        own_prices: {type: boolean, description: false while FLYIL_SHOW_OWN_PRICES is off}
        message: {type: string}
        data_mode: {type: string}
        is_demo: {type: boolean}
        itineraries: {type: array, items: {$ref: '#/components/schemas/Itinerary'}}
        partners: {type: array, items: {$ref: '#/components/schemas/Partner'}}
        white_label: {$ref: '#/components/schemas/WhiteLabel'}
        affiliate_disclosure_he: {type: string}
        affiliate_disclosure_en: {type: string}
    Partner:
      type: object
      properties:
        key: {type: string}
        name: {type: string}
        network: {type: string}
        enabled: {type: boolean}
        visible: {type: boolean}
        disabled_reason: {type: [string, 'null'], enum: [affiliate_disabled, missing_affiliate_id, missing_url_template, invalid_url_template, null]}
        url: {type: [string, 'null']}
        rel: {type: string, const: sponsored noopener}
        shows_price: {type: boolean, const: false}
    WhiteLabel:
      type: object
      properties:
        enabled: {type: boolean}
        url: {type: [string, 'null']}
        provider: {type: string}
        state: {type: string, enum: [live, coming_soon]}
        label_he: {type: [string, 'null']}
        label_en: {type: [string, 'null']}
    PartnerInfo:
      type: object
      properties:
        stage: {type: integer}
        show_own_prices: {type: boolean}
        label_he: {type: string}
        label_en: {type: string}
        rel: {type: string}
        partners: {type: array, items: {$ref: '#/components/schemas/Partner'}}
        white_label: {$ref: '#/components/schemas/WhiteLabel'}
        affiliate_disclosure_he: {type: string}
        affiliate_disclosure_en: {type: string}
x-mcp:
  description: The same data is available to AI assistants through the MCP server (mcp_server/server.py, Streamable HTTP, OAuth or personal token). Read-only tools include search_flights, price_for_route_date and partner_links; they follow the same flag and 300-second rule.
