Getting Started with the Xeni Activities APIHow to Book an ActivityHow to Browse Activity Tags and CategoriesHow to Cancel an Activity BookingHow to Check Activity AvailabilityHow to Get Activity DetailsHow to Retrieve Activity Booking DetailsHow to Search for Activities with FiltersHow to Search for Activity DestinationsCar Rental API - Getting StartedCar Rental API - Understanding Response FieldsHow to Book a Car RentalHow to Get Rental Car Details and Equipment Add-OnsHow to Retrieve or Cancel a Car Rental BookingHow to Search for Available Rental CarsHow to Search for Pickup LocationsHow to Use Car Rental Search FiltersDeals API Best Practices for IntegrationDeals API Frequently Asked QuestionsGetting Started with the Xeni Deals APIDeals API Request Parameters and Headers ReferenceDeals API Supported Currencies and LocalizationHow to Display Deals in Your ApplicationHow to Fetch Hotel Deals by LocationFlights API Error Codes and TroubleshootingGetting Started with the Xeni Flights APIHow to Book a FlightHow to Check Flight Availability and PricingHow to Confirm or Cancel a Flight BookingHow to Retrieve Fare Rules for a FlightHow to Retrieve Flight Booking DetailsHow to Search for Airports Using AutocompleteHow to Search for FlightsHow to Use Flight Search Filters, Sorting, and PaginationHow to Check Room Availability and PricingHow to Filter Vacation Rental ResultsHow to Get Resort Property Details, Amenities, and AccessibilityHow to Hold and Confirm a Resort BookingHow to Release a Resort HoldHow to Retrieve Resort Booking DetailsHow to Search for Available ResortsHow to Search for Resort DestinationsHow to Search for Vacation Rental LocationsHow to Search for Vacation RentalsHow to Use Resort Search Filters and SortingGetting Started with the Xeni Resorts APIResorts API: Understanding Booking Statuses and PoliciesGetting Started with the Vacation Rentals APIVacation Rentals Frequently Asked QuestionsVacation Rentals Supported Property TypesUnderstanding Async Search for Vacation RentalsAuthentication & API SignaturesBooking Hotels — Direct API & SSO CheckoutError Handling, Rate Limits & Best PracticesGetting Started with the Xeni Hotels APIManaging Bookings: Status, Retrieval & CancellationPricing Confirmation & Token LifecycleRetrieving Hotel Details & Room AvailabilitySearching for Hotels: Locations, Filters & PaginationSearching for HotelsSession Management & Correlation IDsAPI authentication and getting your API keys

How to Use Flight Search Filters, Sorting, and Pagination

Last updated: 2026-03-03

How to Use Flight Search Filters, Sorting, and Pagination

The Flights API search endpoint supports filtering, sorting, and pagination to help you narrow down results and build efficient user interfaces. All three are optional parameters on the search request body.

Filters

Add a filters object to your search request to narrow results. All filter fields are optional — include only the ones you need.

Filter Options

FilterTypeValuesDescription
departuretimearray of strings"earlymorning", "morning", "afternoon", "evening"Filter by departure time window.
arrivaltimearray of strings"earlymorning", "morning", "afternoon", "evening"Filter by arrival time window.
baggagearray of strings"cabin", "checked"Only return flights that include the specified baggage type.
stopsarray of strings"nonstop", "onestop", "two_plus", "any"Filter by number of stops.
airlinesarray of stringsAirline namesFilter by specific airlines (e.g., "Alaska Airlines", "United Airlines").

Time Window Definitions

ValueApproximate Time Range
early_morning12:00 AM - 6:00 AM
morning6:00 AM - 12:00 PM
afternoon12:00 PM - 6:00 PM
evening6:00 PM - 12:00 AM

Example: Filtered Search

JSON
{
  "flight_info": [
    {
      "departure_date": "2026-04-15",
      "origin": "SFO",
      "destination": "BLR"
    }
  ],
  "route_type": "Oneway",
  "cabin_type": "economy",
  "adults": 1,
  "filters": {
    "departure_time": [
      "morning",
      "afternoon"
    ],
    "stops": [
      "non_stop",
      "one_stop"
    ],
    "airlines": [
      "United Airlines",
      "Air India"
    ],
    "baggage": [
      "checked"
    ]
  }
}

This request returns economy flights departing in the morning or afternoon, with at most one stop, operated by United Airlines or Air India, and including checked baggage.

Discovering Available Airlines

The search response includes an available_airlines field containing all airlines present in the unfiltered result set. Use this list to populate airline filter options in your UI.

JSON
{
  "available_airlines": [
    "United Airlines",
    "Lufthansa",
    "Air India",
    "Emirates",
    "Alaska Airlines"
  ]
}

Sorting

Add a sorting object to control the order of results.

FieldTypeValuesDescription
sortbystring"price", "duration", "recommended"The field to sort by.
sortorderstring"asc", "desc"Sort direction.

Example: Sort by Price (Lowest First)

JSON
{
  "sorting": {
    "sort_by": "price",
    "sort_order": "asc"
  }
}

Example: Sort by Duration (Shortest First)

JSON
{
  "sorting": {
    "sort_by": "duration",
    "sort_order": "asc"
  }
}

Example: Recommended

JSON
{
  "sorting": {
    "sort_by": "recommended",
    "sort_order": "desc"
  }
}

The recommended sort uses a combination of price, duration, and number of stops to surface the best overall options.

Pagination

Add a pagination object to control the number of results per page and navigate through pages.

FieldTypeDescription
pageintegerThe page number to retrieve (1-based).
limitintegerNumber of results per page.

Example: Paginated Request

JSON
{
  "pagination": {
    "page": 2,
    "limit": 10
  }
}

Pagination Response Fields

The search response includes pagination metadata:

FieldTypeDescription
totalintegerTotal number of matching flights.
pageintegerCurrent page number.
limitintegerResults per page.
totalpagesintegerTotal number of pages.
hasnextbooleanWhether a next page exists.
has_prevbooleanWhether a previous page exists.

Example Pagination Response

JSON
{
  "pagination": {
    "total": 45,
    "page": 2,
    "limit": 10,
    "total_pages": 5,
    "has_next": true,
    "has_prev": true
  }
}

Complete Example

Here is a full search request combining filters, sorting, and pagination:

JSON
{
  "flight_info": [
    {
      "departure_date": "2026-04-15",
      "origin": "SFO",
      "destination": "BLR"
    }
  ],
  "route_type": "Oneway",
  "cabin_type": "economy",
  "adults": 2,
  "children": 1,
  "infants": 0,
  "filters": {
    "departure_time": [
      "morning"
    ],
    "stops": [
      "non_stop"
    ],
    "baggage": [
      "cabin",
      "checked"
    ]
  },
  "sorting": {
    "sort_by": "price",
    "sort_order": "asc"
  },
  "pagination": {
    "page": 1,
    "limit": 20
  }
}

Tips

  • Omit the filters object entirely to return all results without filtering.
  • Use the available_airlines field from the response to build dynamic airline filter lists.
  • Start with page: 1 and use has_next to determine whether to offer a "next page" control.
  • Combining multiple filter values within a field uses OR logic (e.g., ["morning", "afternoon"] returns flights departing in either window).
  • Combining different filter fields uses AND logic (e.g., stops: ["non_stop"] AND airlines: ["United Airlines"] returns only non-stop United flights).

Related Articles

Was this article helpful?