Setting up the Java SDK for Rapid API
Software development kits make integration simple so you can quickly get products to market
Become a partner and get your credentials
For more information, see Getting started with Rapid.
1. Set up a Java development environment
Your development environment needs to have Java 8 or later. You can use Apache Maven or Gradle to configure SDK dependencies for your projects.
2. Create a service client and configure it
To make requests to Rapid endpoints, create a service client and configure it with your credentials.
RapidClient rapidClient =
    RapidClient
        .builder()
        .key("KEY")
        .secret("SECRET")
        .build();3. Make API calls
The service client has a method for each endpoint in the Rapid API. You can access the endpoint by calling the corresponding method with the required parameters.
GetAvailabilityOperationParams getAvailabilityOperationParams = GetAvailabilityOperationParams.builder()
        .checkin("YYYY-MM-DD")
        .checkout("YYYY-MM-DD")
        .currency("USD")
        .language("en_US")
        /* ... */
        .build();
GetAvailabilityOperation getAvailabilityOperation = new GetAvailabilityOperation(getAvailabilityOperationParams);
Response<List<Property>> propertiesResponse = rapidClient.execute(getAvailabilityOperation);
System.out.println(propertiesResponse.getData());Asynchronous execution
The service client also offers asynchronous methods for each endpoint. You can access the endpoint by calling the corresponding asynchronous method with the required parameters.
GetAvailabilityOperationParams getAvailabilityOperationParams = GetAvailabilityOperationParams.builder()
        .checkin("YYYY-MM-DD")
        .checkout("YYYY-MM-DD")
        .currency("USD")
        .language("en_US")
        /* ... */
        .build();
        
GetAvailabilityOperation getAvailabilityOperation = new GetAvailabilityOperation(getAvailabilityOperationParams);
/*  
    The executeAsync method is used to perform an asynchronous operation with the rapidClient, 
    allowing the application to continue executing other tasks while waiting for the operation to complete.
 */
CompleteableFuture getAvailability = rapidClient.executeAsync(getAvailabilityOperation)
        .thenAccept(response -> System.out.println(response.getData()));Need more information? Check out our usage examples. To get better insight into your API calls, configure logging.