This guide will help you get started with integrating the LiteAPI SDK into your Node.js application.

Getting Started with the LiteAPI SDK for Node.js


Installation

To install the LiteAPI Node.js SDK, you can use npm or yarn. Run the following command in your project directory:

npm install liteapi-node-sdk --save

Basic Usage

Here's a step-by-step guide to get you started with using the LiteAPI Node.js SDK in your application.

1. Import the SDK

First, import the LiteAPI SDK into your project and initialize with your API key:

const liteApi = require('liteapi-node-sdk')(YOUR_API_KEY);

Note: you can obtain your API key from the LiteAPI Dashboard.


2. Make your first request

Now you can use the client to make requests to the LiteAPI. Here's an example of how to fetch a list of available flights:

async function fetchRates() {
    try {
        const result = await liteApi.getFullRates({
          checkin: "2024-12-15",
          checkout: "2024-12-18",
          currency: "USD",
          guestNationality: "US",
          hotelIds: ["lp3803c", "lp1f982", "lp19b70", "lp19e75"],
          occupancies: [
              {
                  rooms: 1,
                  adults: 2,
                  children: [2, 3]
              }
          ]
      	});  
      
      	console.log(result);
    } catch (error) {
        console.error('Error fetching rates:', error);
    }
}

fetchRates();

The SDK returns responses as JavaScript promises. You can handle these responses using then and catch for more complex workflows. For a more modern approach, you can use async and await like the example above.

The readme of the SDK in our GitHub repository lists all available methods in the SDK.


Build a fully-fledged web application to book hotels

We have created an open-source example web app using the LiteAPI Node.js SDK, available on GitHub. This example demonstrates the complete process of building a hotel booking website, including checkout, payment, and booking confirmation. Explore the source code here: https://github.com/liteapi-travel/build-website-example


Next steps

For more details and advanced usage, please refer to the GitHub documentation for the SDK.

If you encounter any issues or have any questions, feel free to open an issue on the GitHub repository.

Happy coding!