openapi: 3.0.1
info:
  contact:
    x-twitter: wheretocredit
  description: The Where to Credit API provides mileage earning calculations for frequent flyer programs around the world.
  title: Where to Credit API
  version: "1.0"
  x-apisguru-categories:
    - transport
  x-logo:
    url: https://twitter.com/wheretocredit/profile_image?size=original
  x-origin:
    - format: openapi
      url: https://www.wheretocredit.com/swagger/v1/swagger.json
      version: "3.0"
  x-providerName: wheretocredit.com
security:
  - {}
  - api-key: []
paths:
  /api/1.0/calculate:
    post:
      requestBody:
        content:
          application/json:
            schema:
              description: Collection of <code>Itinerary</code> to allow multiple frequent flyer mile or point calculations at once.
              items:
                $ref: "#/components/schemas/Itinerary"
              nullable: true
              type: array
        description: Collection of <code>Itinerary</code> to allow multiple frequent flyer mile or point calculations at once.
      responses:
        "200":
          content:
            application/json:
              schema:
                items:
                  $ref: "#/components/schemas/CalculateResult"
                type: array
          description: Success.  However individual <code>CalculateResults</code> in the response could have failed.
        "429":
          description: Usage limits exceeded. (Free users only)
      summary: Calculates the number of miles earned for every frequent flyer program.
      tags:
        - Calculate
  /api/1.0/programs:
    get:
      responses:
        "200":
          content:
            application/json:
              schema:
                items:
                  $ref: "#/components/schemas/Program"
                type: array
          description: Success
        "429":
          description: Usage limits exceeded. (Free users only)
      summary: Lists all supported frequent flyer programs.
      tags:
        - Programs
components:
  schemas:
    CalculateItineraryProgramResult:
      properties:
        airlines:
          description: Two-letter IATA carrier codes that are associated with the frequent flyer program.
          items:
            type: string
          nullable: true
          type: array
        id:
          description: Unique identifier for the frequent flyer program. See <code>Programs</code> API.
          nullable: true
          type: string
        name:
          description: Frequent flyer program name. See <code>Programs</code> API.
          nullable: true
          type: string
        revenueBased:
          description: Indicates that the itinerary includes revenue-based miles earnings.
          type: boolean
        unpublished:
          description: Indicates that the itinerary may be missing miles due to unpublished earning rates from the program.
          type: boolean
        value:
          description: Total redeemable miles or points earned for the frequent flyer program.
          format: int32
          type: integer
      type: object
    CalculateItineraryResult:
      properties:
        id:
          description: Unique identifier provided for this itinerary.
          nullable: true
          type: string
        totals:
          description: Total miles earned for each frequent flyer program.
          items:
            $ref: "#/components/schemas/CalculateItineraryProgramResult"
          nullable: true
          type: array
      type: object
    CalculateResult:
      properties:
        errorMessage:
          description: Error message if the API call was not successful.
          nullable: true
          type: string
        success:
          description: Indicates whether the API call was successful.
          type: boolean
        value:
          $ref: "#/components/schemas/CalculateItineraryResult"
      type: object
    Itinerary:
      properties:
        baseFareUSD:
          description: Amount in USD that will be used to calculate revenue program mileage earning.  This amount should generally include carrier imposed surcharges but exclude other taxes. Default is 0.
          format: double
          type: number
        id:
          description: Unique identifier for this itinerary that will be passed back to help correlate a result.
          nullable: true
          type: string
        segments:
          description: Every flight transfer or stopover should be considered a separate segment.
          items:
            $ref: "#/components/schemas/Segment"
          type: array
        ticketingCarrier:
          description: Two-letter IATA carrier code for the ticketing or plating airline.  This is used for revenue programs (i.e. UA, DL, B6).  Leaving this value blank will exclude revenue programs.
          nullable: true
          type: string
      required:
        - segments
      type: object
    Program:
      properties:
        airlines:
          description: Two-letter IATA carrier codes that are associated with the frequent flyer program.
          items:
            type: string
          nullable: true
          type: array
        denomination:
          description: Name of the unit of a mile or point.
          nullable: true
          type: string
        fullName:
          description: Full name of the frequent flyer program including the airline, if applicable.
          nullable: true
          type: string
        id:
          description: Unique identifier for the frequent flyer program.
          nullable: true
          type: string
        programName:
          description: Name of the frequent flyer program.
          nullable: true
          type: string
        tierNames:
          description: Name of each tier level for the frequent flyer program.
          items:
            type: string
          nullable: true
          type: array
      type: object
    Segment:
      properties:
        bookingClass:
          description: Single-letter booking class used to determine the earning rate for the flight segment.
          type: string
        carrier:
          description: "Two-letter IATA carrier code for the marketing airline.  This is used to determine which earnings chart will be applied for this segment.\r

            NOTE: Frequent flyer programs based on operating carrier, including but not limited to Star Alliance carriers, cannot be reliably mapped to a booking class and will not be accurately reflected in this API."
          type: string
        departure:
          description: The date on the flight will depart from the origin to go to the destination.  This is used to determine which earnings chart will be in effect at time of departure.
          format: date-time
          nullable: true
          type: string
        destination:
          description: Three-letter IATA airport code to which the flight is going.
          type: string
        distance:
          description: The number of miles for this flight segment.  Otherwise, distance is calculated using the great-circle distance between the origin and destination and may not match other data sources exactly.
          format: double
          nullable: true
          type: number
        flightNumber:
          description: The airline identifier for the flight segment, most commonly (but not always) a number and is used for earning charts that are restricted to specific flight numbers.
          format: int32
          nullable: true
          type: integer
        operatingCarrier:
          description: Two-letter IATA carrier code for the operating airline.  This value is only used when earning is based on marketing carrier but restricted to a specific operating carrier.  Leaving this value blank will assume the flight is operated by the marketing carrier.
          nullable: true
          type: string
        origin:
          description: Three-letter IATA airport code from which the flight will depart.
          type: string
      required:
        - bookingClass
        - carrier
        - destination
        - origin
      type: object
  securitySchemes:
    api-key:
      description: Subscribers only
      in: header
      name: Authorization-Token
      type: apiKey
