{
    "openapi": "3.0.3",
    "info": {
        "title": "FareEagle Travel API",
        "description": "Search and book flights, hotels, and buses across India and worldwide. FareEagle is an Indian online travel agency (OTA). All prices are in INR and include taxes. Booking links take users to fareeagle.com to complete the booking.",
        "version": "1.0.0",
        "contact": {
            "name": "FareEagle Support",
            "email": "support@fareeagle.com",
            "url": "https://www.fareeagle.com/contact.php"
        }
    },
    "servers": [
        {
            "url": "https://www.fareeagle.com/api/v1",
            "description": "Production"
        }
    ],
    "paths": {
        "/flights/search": {
            "get": {
                "operationId": "searchFlights",
                "summary": "Search flights between two cities",
                "description": "Returns flight options with airlines, schedules, prices (INR), and booking links. Supports IATA codes or city names.",
                "parameters": [
                    {"name": "from", "in": "query", "required": true, "schema": {"type": "string"}, "description": "Origin IATA code or city name (e.g. DEL, Delhi)"},
                    {"name": "to", "in": "query", "required": true, "schema": {"type": "string"}, "description": "Destination IATA code or city name"},
                    {"name": "date", "in": "query", "required": true, "schema": {"type": "string", "format": "date"}, "description": "Travel date (YYYY-MM-DD)"},
                    {"name": "return_date", "in": "query", "schema": {"type": "string", "format": "date"}, "description": "Return date for round trips"},
                    {"name": "adults", "in": "query", "schema": {"type": "integer", "default": 1}, "description": "Number of adults"},
                    {"name": "children", "in": "query", "schema": {"type": "integer", "default": 0}, "description": "Number of children"},
                    {"name": "class", "in": "query", "schema": {"type": "string", "default": "Economy", "enum": ["Economy", "PremiumEconomy", "Business", "First"]}}
                ],
                "responses": {
                    "200": {
                        "description": "Flight search results",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {"type": "boolean"},
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "flights": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "object",
                                                        "properties": {
                                                            "airline": {"type": "string"},
                                                            "flight_number": {"type": "string"},
                                                            "departure": {"type": "object"},
                                                            "arrival": {"type": "object"},
                                                            "duration": {"type": "string"},
                                                            "stops": {"type": "integer"},
                                                            "price": {"type": "object"},
                                                            "booking_url": {"type": "string"}
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/hotels/search": {
            "get": {
                "operationId": "searchHotels",
                "summary": "Search hotels in a city",
                "description": "Returns hotel options with names, star ratings, prices per night (INR), and booking links.",
                "parameters": [
                    {"name": "city", "in": "query", "required": true, "schema": {"type": "string"}, "description": "City name (e.g. Goa, Mumbai)"},
                    {"name": "checkin", "in": "query", "required": true, "schema": {"type": "string", "format": "date"}},
                    {"name": "checkout", "in": "query", "required": true, "schema": {"type": "string", "format": "date"}},
                    {"name": "rooms", "in": "query", "schema": {"type": "integer", "default": 1}},
                    {"name": "guests", "in": "query", "schema": {"type": "integer", "default": 2}}
                ],
                "responses": {
                    "200": {"description": "Hotel search results"}
                }
            }
        },
        "/buses/search": {
            "get": {
                "operationId": "searchBuses",
                "summary": "Search buses between two Indian cities",
                "parameters": [
                    {"name": "from", "in": "query", "required": true, "schema": {"type": "string"}},
                    {"name": "to", "in": "query", "required": true, "schema": {"type": "string"}},
                    {"name": "date", "in": "query", "required": true, "schema": {"type": "string", "format": "date"}}
                ],
                "responses": {
                    "200": {"description": "Bus search results"}
                }
            }
        },
        "/airports/info": {
            "get": {
                "operationId": "getAirportInfo",
                "summary": "Get airport information",
                "description": "Returns terminal info, transport options, facilities, airlines, and tips for any airport.",
                "parameters": [
                    {"name": "code", "in": "query", "schema": {"type": "string"}, "description": "IATA code (e.g. HYD)"},
                    {"name": "city", "in": "query", "schema": {"type": "string"}, "description": "City name (alternative to code)"}
                ],
                "responses": {
                    "200": {"description": "Airport information"}
                }
            }
        },
        "/airlines/info": {
            "get": {
                "operationId": "getAirlineInfo",
                "summary": "Get airline information",
                "description": "Returns check-in links, baggage policy, PNR status, and fleet info.",
                "parameters": [
                    {"name": "code", "in": "query", "schema": {"type": "string"}, "description": "IATA airline code (e.g. 6E)"},
                    {"name": "name", "in": "query", "schema": {"type": "string"}, "description": "Airline name or slug"}
                ],
                "responses": {
                    "200": {"description": "Airline information"}
                }
            }
        },
        "/flights/prepare-booking": {
            "post": {
                "operationId": "prepareBooking",
                "summary": "Confirm fare and prepare a flight booking",
                "description": "Takes a booking_token from search results, calls fare quote to confirm current price, and returns a booking session. Use this before create-booking to verify the fare is still available.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": ["booking_token"],
                                "properties": {
                                    "booking_token": {"type": "string", "description": "The booking_token from a flight in search results"}
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Fare confirmed with booking session",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "fare_confirmed": {"type": "boolean"},
                                        "price": {"type": "object", "properties": {"amount": {"type": "number"}, "currency": {"type": "string"}, "formatted": {"type": "string"}}},
                                        "price_changed": {"type": "boolean"},
                                        "passengers_required": {"type": "array"},
                                        "booking_session": {"type": "string"},
                                        "session_expires_in": {"type": "integer"}
                                    }
                                }
                            }
                        }
                    },
                    "410": {"description": "Fare expired — search again"}
                }
            }
        },
        "/flights/create-booking": {
            "post": {
                "operationId": "createBooking",
                "summary": "Create a flight booking with passenger details",
                "description": "Takes the booking_session from prepare-booking plus passenger details and contact info. Returns a payment URL for the user to complete payment on fareeagle.com.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": ["booking_session", "passengers", "contact"],
                                "properties": {
                                    "booking_session": {"type": "string", "description": "Session token from prepare-booking"},
                                    "passengers": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "required": ["first_name", "last_name", "date_of_birth"],
                                            "properties": {
                                                "title": {"type": "string", "enum": ["Mr", "Mrs", "Ms", "Mstr", "Miss"]},
                                                "first_name": {"type": "string"},
                                                "last_name": {"type": "string"},
                                                "date_of_birth": {"type": "string", "description": "YYYY-MM-DD"},
                                                "gender": {"type": "string", "enum": ["M", "F"]},
                                                "passport_number": {"type": "string"},
                                                "passport_expiry": {"type": "string"},
                                                "nationality": {"type": "string", "description": "2-letter country code, default IN"}
                                            }
                                        }
                                    },
                                    "contact": {
                                        "type": "object",
                                        "required": ["email", "phone"],
                                        "properties": {
                                            "email": {"type": "string"},
                                            "phone": {"type": "string"}
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Booking created, payment pending",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "booking_reference": {"type": "string"},
                                        "status": {"type": "string"},
                                        "total_amount": {"type": "object", "properties": {"amount": {"type": "number"}, "formatted": {"type": "string"}}},
                                        "payment_url": {"type": "string"},
                                        "payment_expires_in": {"type": "integer"}
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}