All requests to LiteAPI must be authenticated using an API key. You can find your API key in the LiteAPI dashboard. An account provides analytics and management for all bookings through the attached API keys.
To authenticate against LiteAPI's REST APIs, include the X-API-Key
header in your HTTP requests, setting its value to your personal API key.
This API key grants access to the API and must be kept confidential to prevent unauthorized use. Ensure you securely store the API key and avoid exposing it in public or client-side code repositories. This header ensures that your requests are authenticated and authorized to interact with LiteAPI's services.
curl -X GET "https://api.liteapi.travel/v3.0/data/hotels?countryCode=IT&cityName=Rome" -H "X-API-Key: YOUR_API_KEY"
import requests
api_key = 'YOUR_API_KEY'
url = 'https://api.liteapi.travel/v3.0/data/hotels?countryCode=IT&cityName=Rome'
headers = {
'X-API-Key': api_key
}
response = requests.get(url, headers=headers)
data = response.json()
print(data)
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
apiKey := "YOUR_API_KEY"
url := "https://api.liteapi.travel/v3.0/data/hotels?countryCode=IT&cityName=Rome"
client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("X-API-Key", apiKey)
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
<?php
$apiKey = 'YOUR_API_KEY';
$url = 'https://api.liteapi.travel/v3.0/data/hotels?countryCode=IT&cityName=Rome';
$options = [
'http' => [
'header' => "X-API-Key: $apiKey\r\n"
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$data = json_decode($response, true);
print_r($data);
?>
const https = require('https');
const apiKey = 'YOUR_API_KEY';
const url = 'https://api.liteapi.travel/v3.0/data/hotels?countryCode=IT&cityName=Rome';
const options = {
headers: {
'X-API-Key': apiKey
}
};
https.get(url, options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log(JSON.parse(data));
});
}).on('error', (e) => {
console.error(e);
});
Sample Sandbox API Key:
To help you get started quickly, we provide a sandbox API key that you can use for testing purposes. Note that this key has limited permissions and can only be used for sandbox testing. Sandbox API Key:
sand_c0155ab8-c683-4f26-8f94-b5e92c5797b9
Example Request Using Sandbox API Key:
curl -X GET "https://api.liteapi.travel/v3.0/data/hotels?countryCode=IT&cityName=Rome" -H "X-API-Key: sand_c0155ab8-c683-4f26-8f94-b5e92c5797b9"
Security Best Practices:
- Keep your API key secure. Do not expose it in client-side code.
- Rotate your API keys regularly.
- Use environment variables to manage your API keys.