openapi: 3.1.0
info:
  title: Award Travel Finder API
  description: Search for award flight and hotel availability using loyalty points and miles across 17+ airlines and 8 hotel programs.
  version: 1.0.0
servers:
  - url: https://awardtravelfinder.com/api/v1/chatgpt
    description: Production server

paths:
  /airlines:
    get:
      operationId: listAirlines
      summary: List all supported airlines
      description: Returns all airlines available for award flight search, including their loyalty currency and whether results are immediate or async.
      responses:
        "200":
          description: List of supported airlines
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      airlines:
                        type: array
                        items:
                          $ref: "#/components/schemas/Airline"

  /airports:
    get:
      operationId: lookupAirports
      summary: Look up airports by code or name
      description: Search for airports by IATA code (e.g. LHR) or by city/airport name (e.g. London, Heathrow). Use this to verify airport codes before searching for flights.
      parameters:
        - name: query
          in: query
          required: true
          description: Airport IATA code (e.g. LHR) or partial city/airport name (e.g. London)
          schema:
            type: string
      responses:
        "200":
          description: Matching airports
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      airports:
                        type: array
                        items:
                          $ref: "#/components/schemas/Airport"
                      message:
                        type: string

  /route_airlines:
    get:
      operationId: getRouteAirlines
      summary: Get airlines serving a route
      description: Returns which airlines fly between two airports. Use this before searching to know which airlines serve a route.
      parameters:
        - name: departure
          in: query
          required: true
          description: Departure airport IATA code (e.g. LHR)
          schema:
            type: string
            minLength: 3
            maxLength: 3
        - name: destination
          in: query
          required: true
          description: Destination airport IATA code (e.g. JFK)
          schema:
            type: string
            minLength: 3
            maxLength: 3
      responses:
        "200":
          description: Airlines serving this route
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      departure:
                        type: string
                      destination:
                        type: string
                      airlines:
                        type: array
                        items:
                          $ref: "#/components/schemas/Airline"

  /search:
    get:
      operationId: searchAwardFlights
      summary: Search award flight availability
      description: Search award flights for a specific airline, route, and date. Async airlines return a cache_key — use search_status to poll for results.
      parameters:
        - name: airline
          in: query
          required: true
          description: "Airline slug (e.g. british-airways, qatar-airways). Use /airlines to see all options."
          schema:
            type: string
        - name: departure
          in: query
          required: true
          description: Departure airport IATA code (e.g. LHR)
          schema:
            type: string
            minLength: 3
            maxLength: 3
        - name: destination
          in: query
          required: true
          description: Destination airport IATA code (e.g. JFK)
          schema:
            type: string
            minLength: 3
            maxLength: 3
        - name: date
          in: query
          required: true
          description: Travel date in YYYY-MM-DD format (must be in the future, within 12 months)
          schema:
            type: string
            format: date
      responses:
        "200":
          description: Award flight availability results
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: "#/components/schemas/FlightSearchResult"

  /search_all:
    get:
      operationId: searchAllAirlines
      summary: Search all airlines for a route
      description: |
        Search for award availability across ALL airlines that fly a specific route.
        Use this when the user doesn't specify a particular airline or wants to compare options.
        Some airlines return immediate results, others return a cache_key for async polling.
      parameters:
        - name: departure
          in: query
          required: true
          description: Departure airport IATA code (e.g. LHR)
          schema:
            type: string
            minLength: 3
            maxLength: 3
        - name: destination
          in: query
          required: true
          description: Destination airport IATA code (e.g. JFK)
          schema:
            type: string
            minLength: 3
            maxLength: 3
        - name: date
          in: query
          required: true
          description: Travel date in YYYY-MM-DD format
          schema:
            type: string
            format: date
      responses:
        "200":
          description: Results from all airlines (some immediate, some pending)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      departure:
                        type: string
                      destination:
                        type: string
                      date:
                        type: string
                      airlines_searched:
                        type: array
                        items:
                          type: string
                      immediate_results:
                        type: object
                        additionalProperties:
                          $ref: "#/components/schemas/FlightSearchResult"
                      pending_searches:
                        type: object
                        additionalProperties:
                          type: object
                          properties:
                            status:
                              type: string
                            cache_key:
                              type: string
                            message:
                              type: string

  /search_status:
    get:
      operationId: checkSearchStatus
      summary: Check async search status
      description: |
        Check the status of an async flight search that returned a cache_key.
        The server will wait up to 75 seconds for results before returning.
        If status is still "pending", try again after 30 seconds.
      parameters:
        - name: airline
          in: query
          required: true
          description: The airline slug from the original search
          schema:
            type: string
        - name: cache_key
          in: query
          required: true
          description: The cache_key returned from the initial search
          schema:
            type: string
      responses:
        "200":
          description: Search status and results if complete
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      status:
                        type: string
                        enum: [complete, pending, error]
                      airline:
                        type: string
                      flights:
                        type: array
                        items:
                          $ref: "#/components/schemas/Flight"
                      message:
                        type: string

  /hotels/search:
    get:
      operationId: searchHotels
      summary: Search for hotels
      description: Search for hotels by name, city, or brand. Returns hotel IDs needed for availability searches.
      parameters:
        - name: query
          in: query
          required: true
          description: "Hotel name or city (e.g. 'Marriott Tokyo', 'Paris', 'JW Marriott')"
          schema:
            type: string
        - name: brand
          in: query
          required: false
          description: Filter by hotel brand/program
          schema:
            type: string
            enum: [marriott, hilton, hyatt, ihg, wyndham, choice, accor, radisson]
        - name: limit
          in: query
          required: false
          description: Maximum results to return (default 20, max 50)
          schema:
            type: integer
            default: 20
            maximum: 50
      responses:
        "200":
          description: Matching hotels
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      query:
                        type: string
                      brand:
                        type: string
                      hotels_found:
                        type: integer
                      hotels:
                        type: array
                        items:
                          $ref: "#/components/schemas/Hotel"

  /hotels/availability:
    get:
      operationId: getHotelAvailability
      summary: Get hotel award availability
      description: Get award availability and pricing for a specific hotel on a given date. Returns room types, points required, and cash rates.
      parameters:
        - name: hotel_id
          in: query
          required: true
          description: Hotel ID from a previous hotel search result
          schema:
            type: string
        - name: check_in_date
          in: query
          required: true
          description: Check-in date in YYYY-MM-DD format
          schema:
            type: string
            format: date
        - name: nights
          in: query
          required: false
          description: Number of nights (default 1)
          schema:
            type: integer
            default: 1
      responses:
        "200":
          description: Hotel award availability
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      hotel_id:
                        type: string
                      check_in_date:
                        type: string
                      nights:
                        type: integer
                      rooms_found:
                        type: integer
                      rooms:
                        type: array
                        items:
                          $ref: "#/components/schemas/HotelRoom"

  /hotels/brands:
    get:
      operationId: listHotelBrands
      summary: List hotel loyalty programs
      description: Get all supported hotel loyalty programs and their sub-brands.
      responses:
        "200":
          description: Hotel brand hierarchy
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      brands_count:
                        type: integer
                      brands:
                        type: array
                        items:
                          $ref: "#/components/schemas/HotelBrand"

  /status_matches:
    get:
      operationId: getStatusMatches
      summary: Get active status match offers
      description: |
        Returns current airline status match promotions where you can match elite status from one airline to another.
        Each campaign includes a direct apply link and a detailed FAQ page URL with eligibility requirements.
        Filter by alliance to narrow results.
      parameters:
        - name: alliance
          in: query
          required: false
          description: "Filter by airline alliance"
          schema:
            type: string
            enum: [SkyTeam, Star Alliance, oneworld]
      responses:
        "200":
          description: Active status match campaigns
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      campaigns:
                        type: array
                        items:
                          $ref: "#/components/schemas/StatusMatch"
                      count:
                        type: integer

  /valuations:
    get:
      operationId: getValuations
      summary: Get points valuations or calculate portfolio value
      description: |
        Without parameters: returns all 29 loyalty programs with their cents-per-point (cpp) valuations.
        With programs parameter: calculates the total USD value of a points portfolio.
        Example: /valuations?programs[british-airways]=100000&programs[marriott-bonvoy]=200000
      parameters:
        - name: programs
          in: query
          required: false
          description: "Map of program slugs to balances. Example: programs[british-airways]=100000"
          schema:
            type: object
            additionalProperties:
              type: integer
      responses:
        "200":
          description: Valuations list or portfolio calculation
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object

components:
  schemas:
    Airline:
      type: object
      properties:
        slug:
          type: string
          description: "Airline identifier used in search requests (e.g. british-airways)"
        name:
          type: string
          description: "Display name (e.g. British Airways)"
        code:
          type: string
          description: "IATA airline code (e.g. BA)"
        currency:
          type: string
          description: "Loyalty currency name (e.g. Avios)"
        search_type:
          type: string
          enum: [immediate, async]
          description: "Whether results come back instantly or require polling"

    Airport:
      type: object
      properties:
        code:
          type: string
          description: "IATA airport code (e.g. LHR)"
        name:
          type: string
          description: "Airport name (e.g. London Heathrow)"
        city:
          type: string
        country:
          type: string

    FlightSearchResult:
      type: object
      properties:
        airline:
          type: string
        route:
          type: string
        date:
          type: string
        flights_found:
          type: integer
        flights:
          type: array
          items:
            $ref: "#/components/schemas/Flight"
        status:
          type: string
          description: "For async searches: 'pending' with a cache_key"
        cache_key:
          type: string
          description: "For async searches: use with search_status to poll for results"
        message:
          type: string
        error:
          type: string

    Flight:
      type: object
      properties:
        duration:
          type: string
          description: "Flight duration (e.g. 7h 30m)"
        segments:
          type: array
          items:
            type: string
          description: "Route segments (e.g. LHR -> JFK (BA117))"
        cabins:
          type: array
          items:
            $ref: "#/components/schemas/Cabin"
        booking_url:
          type: string

    Cabin:
      type: object
      properties:
        cabin:
          type: string
          description: "Cabin class (economy, business, first, etc.)"
        points:
          type: integer
          description: "Points/miles required"
        taxes:
          type: number
          description: "Taxes and fees amount"
        taxes_currency:
          type: string
          description: "Currency for taxes (e.g. USD, GBP)"
        seats:
          type: integer
          description: "Number of available seats"

    Hotel:
      type: object
      properties:
        id:
          type: string
          description: "Hotel ID for use in availability searches"
        name:
          type: string
        brand:
          type: string
        sub_brand:
          type: string
        city:
          type: string
        country:
          type: string

    HotelRoom:
      type: object
      properties:
        room_type:
          type: string
        rate_plan:
          type: string
        points:
          type: integer
          description: "Points required per night"
        points_display:
          type: string
        cash_rate_usd:
          type: number
          description: "Cash rate in USD for comparison"
        rooms_available:
          type: integer

    HotelBrand:
      type: object
      properties:
        name:
          type: string
          description: "Brand name (e.g. Marriott Bonvoy)"
        program:
          type: string
          description: "Loyalty program name"
        sub_brands:
          type: array
          items:
            type: string
          description: "Sub-brands (e.g. JW Marriott, Ritz-Carlton, etc.)"

    StatusMatch:
      type: object
      properties:
        slug:
          type: string
          description: "Campaign identifier (e.g. etihad, flying-blue)"
        name:
          type: string
          description: "Campaign name"
        airline:
          type: string
          description: "Airline name (null for non-airline campaigns)"
        alliance:
          type: string
          description: "Airline alliance (SkyTeam, Star Alliance, oneworld, or null)"
        url:
          type: string
          description: "Direct apply link with affiliate tracking"
        info_url:
          type: string
          description: "FAQ page URL with eligibility details and step-by-step instructions"
        active:
          type: boolean

