Async API Flows - Implementation Guide

👍

Please refer to the 'HSP Flows: Step-by-Step Implementation Guide' article.

This guide focuses specifically on the Search and Get Async Results requests, while the former article outlines the steps required prior to Implementation itself.

Overview

The Async API flows enhances the standard Hotels and B2C Wrapper searches by adding asynchronous search capabilities.

This means initial search results are returned within seconds, allowing you to display them to users almost instantly. Meanwhile, the remaining results are retrieved in the background, delivered in chunks to improve response times and provide a smoother experience for your users.

Key Features

  • Faster Response Times: Asynchronous search returns initial search results within a few seconds (e.g. 2-3 seconds), allowing you to display options to the end users almost immediately.
  • Customizable Timeouts: Asynchronous search allows clients to define timeouts and prioritize how quickly results are returned.
  • Enhanced User Experience: The asynchronous flow enables partners to immediately display hotel and room options to end users, removing the need to wait for all results to be collected.
  • Dynamic Updates: The "Get Async Results" function allows partners to dynamically update and display new options as they become available, enhancing the user experience by offering more choices over time.
  • Full Coverage of Hotel and Room Offerings: By using the Async flow, partners can ensure that all hotel and room options are included in their feeds.

How the Async flow works ?

Hotel Search - Standard Flow

Example - Explained :

  • The timeout is set to 20 seconds.
  • All searches to suppliers are stopped after 20 seconds.
  • Supplier responses received after the 20-second timeout are excluded from the results.
  • First Response Time: 20 Sec.
  • Result : Supplier Responses which returned after the Timeout - are excluded from the Results.

Hotel Search - Async Flow

Example - Explained :

  • "AwaitTimeForInitialResults" is set to 2 seconds.
  • The timeout is set to 20 seconds.
  • All results received within the first 2 seconds are returned as the 'First Search Response.'
  • Searches to suppliers proceeding to be initiated and aggregated.
  • Each "Get Async Results" request will return all results collected up to that point.
  • First Response Time: 2 Sec.
  • Result : Ensures that 100% of supplier results are included in your opportunities and offerings.

Implementation Guide & Notes

Step 1 - Define Timeouts

The Search Async Flow uses two key parameters to control its behavior and response times:

  • 'AwaitTimeForInitialResults':
    This parameter specifies the duration for the 'First Search Response'.
    For example: if set to 2 seconds, the first set of results will be returned after 2 seconds. Meanwhile, the asynchronous process will continue running in the background, collecting further responses from suppliers.
  • 'TimeoutSeconds':
    This parameter sets the total duration for the API to gather responses.
    For example: if set to 20 seconds, the system will collect all supplier responses received within this time frame. These results will be available and returned when the "Get Async Results" Request is called.

Step 2 - Understanding 'Search Async' & 'Get Async Results'

The retrieval of results in the Async Flow can occur multiple times throughout the session:

  • 'Search Async':
    The 'Search Async' request starts a search with your connected suppliers. The 'First Search Response' will be provided within the timeout defined in the 'AwaitTimeForInitialResults' parameter, returning any results received within that timeframe.
  • 'Get Async Results':
    The 'Get Async Results' request retrieves all the results received up to that point in the search process. This request can be made multiple times throughout the flow and can be initiated at any stage (GetPackages, Cxl-Policy, Payment Pref, etc.)

Step 3 - Define a 'Get Async Results' trigger

After the 'First Search Response' is returned, several triggers can be used to call the 'Get Async Results' to obtain additional results received since the initial response. These triggers can include:

  • Predefined Time Slots: Partners can set a trigger to call 'Get Async Results' at regular intervals (e.g., every X seconds), allowing new results to be retrieved and displayed at each interval.
  • User Action - Scrolling: Partners can configure a trigger to call 'Get Async Results' when the user scrolls to the end of the currently displayed results, automatically loading and presenting more hotel options.
  • User Action - 'Refresh Results' Button: Partners can implement a 'Refresh Results' button - when clicked, will call 'Get Async Results' to fetch and display additional results / hotel options to the user.
  • Custom Triggers: Partners can define other custom triggers based on specific user behaviors or conditions, such as reaching a certain number of displayed results or user inactivity, to optimize the timing and frequency of 'Get Async Results' calls.

Additional Requests

All additional requests (such as GetPage, GetPackages, Get Cancellation Policy, Get Payment Preferences etc) remain unchanged and can be made either before or after the "Get Async Results."

As shown in the following flowchart, the process can proceed to the "GetPackages" step once the 'first search response' is returned. After this, partners can initiate the "Get Async Results" and make another "GetPackages" call based on the hotels returned up to that point.

This approach applies to all request types, including GetPage, GetPackages, Get Cancellation Policy, Get Payment Preferences, and Get Hotel Content.

This means each of these requests can be called per hotels returned in the 'First Search Response' or the 'Get Async Results'.

Hence, each request is available and should be made only for the hotels retrieved up to that point.

Having said that :

👍

Important Note :

The implementation differences are only per the Search Step, this guide focuses exclusively on the 'Search' and 'Get Async Results' requests.

As all additional requests remain unchanged.

To see full Documentation of the Hotels Async API - Click here.
To see full Documentation of the B2C Wrapper Async API - Click here.