openapi: 3.0.0
info:
  title: Ryanair Flights API
  description: |
    Search Ryanair flights between two airports or cities, one way or round trip, on a date and up to 3 days either side, for a party of up to 25.
    Each flight returns its times at both airports in local time and UTC, its duration, the fare for each passenger type, the total for the party, the seats left at that fare when Ryanair shows them, and the infant places left.

    **Cross-linking**: For prices across airlines on the same route, use the Google Flights API, the Skyscanner Flights API or the Kayak Flights API.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Ryanair Flights Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Engine used to retrieve the results.
          schema:
            type: string
            enum: ["ryanair_flights"]
        - name: departure_id
          in: query
          required: true
          description: Ryanair airport code or city code of the departure, for example DUB, or LON for every London airport Ryanair flies from.
          schema:
            type: string
            pattern: '^\s*[A-Za-z]{3}\s*$'
        - name: arrival_id
          in: query
          required: true
          description: Ryanair airport code or city code of the arrival, for example STN, or MIL for every Milan airport Ryanair flies to, different from departure_id.
          schema:
            type: string
            pattern: '^\s*[A-Za-z]{3}\s*$'
        - name: outbound_date
          in: query
          required: true
          description: 'Departure date, from today. Format: YYYY-MM-DD'
          schema:
            type: string
            format: date
        - name: return_date
          in: query
          required: false
          description: 'Return date of a round trip, on or after outbound_date. Format: YYYY-MM-DD'
          schema:
            type: string
            format: date
        - name: flight_type
          in: query
          required: false
          description: Type of trip, where a round trip needs return_date.
          schema:
            type: string
            enum: ["round_trip", "one_way"]
            default: "round_trip"
        - name: adults
          in: query
          required: false
          description: Number of adult passengers, aged 16 or older.
          schema:
            type: integer
            minimum: 1
            maximum: 25
            default: 1
        - name: children_ages
          in: query
          required: false
          description: Comma-separated ages of child passengers from 0 to 15, where ages 0 and 1 travel on an adult's lap, 2 to 11 fly as children and 12 to 15 as teens. A search takes at most 25 adults and children aged 2 or older, at most one child aged 0 or 1 per adult and at most 18 children aged 0 or 1.
          schema:
            type: string
            pattern: '^\s*\d{1,2}\s*(,\s*\d{1,2}\s*)*$'
        - name: flex_days
          in: query
          required: false
          description: Days searched before and after each date, so 3 returns the flights of up to 7 dates per leg.
          schema:
            type: integer
            minimum: 0
            maximum: 3
            default: 0
      responses:
        '200':
          description: Successful response. A search with no Ryanair flight on its dates, or with a code Ryanair does not fly from or to, carries an error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      required: [search_metadata, search_parameters]
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        outbound_flights:
          type: array
          description: Ryanair flights from departure_id to arrival_id on the searched dates.
          items:
            $ref: '#/components/schemas/Flight'
        return_flights:
          type: array
          description: Ryanair flights back from arrival_id to departure_id on the searched return dates.
          items:
            $ref: '#/components/schemas/Flight'
        error:
          type: string
          description: Message explaining why the search has no flights.
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: "Unique identifier for the search request"
        status:
          type: string
          description: "Status of the search request"
        created_at:
          type: string
          format: date-time
          description: "Timestamp when the search was created"
        request_time_taken:
          type: number
          description: "Time taken to make the request in seconds"
        parsing_time_taken:
          type: number
          description: "Time taken to parse the results in seconds"
        total_time_taken:
          type: number
          description: "Total time taken for the search in seconds"
        request_url:
          type: string
          description: "Ryanair URL for this search"
        html_url:
          type: string
          description: "URL to view HTML results"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      required: [engine, departure_id, arrival_id, outbound_date, flight_type]
      properties:
        engine:
          type: string
          description: Engine used for the search.
        departure_id:
          type: string
          description: Departure airport or city code.
        arrival_id:
          type: string
          description: Arrival airport or city code.
        outbound_date:
          type: string
          description: Departure date.
        return_date:
          type: string
          description: Return date of a round trip.
        flight_type:
          type: string
          description: Type of trip.
        adults:
          type: integer
          description: Number of adult passengers.
        children_ages:
          type: string
          description: Ages of child passengers.
        flex_days:
          type: integer
          description: Days searched before and after each date.
    SearchInformation:
      type: object
      required: [currency]
      properties:
        currency:
          type: string
          description: ISO 4217 code of the currency of every price, which Ryanair sets by the departure airport.
    Flight:
      type: object
      required: [flight_number, airline_code, departure_airport, arrival_airport, duration, infants_left]
      properties:
        flight_number:
          type: string
          description: Airline code and flight number.
        airline_code:
          type: string
          description: Two-character code of the airline that sells the flight.
        operating_airline:
          type: string
          description: Airline that operates the flight for the selling airline.
        departure_airport:
          $ref: '#/components/schemas/Airport'
        arrival_airport:
          $ref: '#/components/schemas/Airport'
        duration:
          type: integer
          description: Duration of the flight in minutes.
        price:
          type: number
          description: Fare for one adult, taxes included.
        original_price:
          type: number
          description: Fare for one adult before Ryanair's discount.
        passenger_prices:
          type: array
          description: Fare for each passenger type of the party, with the number of passengers of that type.
          items:
            $ref: '#/components/schemas/PassengerPrice'
        total_price:
          type: number
          description: Sum of the fares and infant fees of the whole party, as Ryanair lists them.
        has_buy_one_get_one_offer:
          type: boolean
          description: Whether Ryanair marks the flight's fares with its buy one, get one offer.
        seats_left:
          type: integer
          minimum: 1
          maximum: 5
          description: Seats left at this fare, which Ryanair shows from 5 seats down.
        infants_left:
          type: integer
          description: Places left on the flight for infants on an adult's lap.
        is_sold_out:
          type: boolean
          description: Whether Ryanair sells no fare on this flight for the party.
    Airport:
      type: object
      required: [id, date, time, datetime_utc]
      properties:
        id:
          type: string
          description: IATA code of the airport.
        name:
          type: string
          description: Name of the airport.
        date:
          type: string
          description: 'Local date. Format: YYYY-MM-DD'
        time:
          type: string
          description: 'Local time. Format: HH:MM'
        datetime_utc:
          type: string
          format: date-time
          description: Date and time in UTC.
    PassengerPrice:
      type: object
      required: [type, price, count]
      properties:
        type:
          type: string
          enum: ["adult", "teen", "child", "infant"]
          description: Passenger type.
        price:
          type: number
          description: Fare for one passenger of this type, taxes included.
        original_price:
          type: number
          description: Fare for one passenger of this type before Ryanair's discount.
        count:
          type: integer
          description: Number of passengers of this type.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
