Documentation: Fresh Cache API

With this API, you can identify which hotel searches have experienced price or availability changes in Veturis. This information is highly useful for updating your Veturis cache or even invalidating your cache with other providers, thereby improving your cache quality. By default, the API reports availabilities with price or availability changes within the last 24 hours. The API includes up to the last 10000 availabilities that have changed.

API Endpoint

URL: https://fresh.cache.veturis.com:/yourEndPoint.php

Request Parameters

Parameter Type Required Description
password string Yes The password for authenticating the request.
asXML boolean No If set to true, the response includes cache data in XML format.
all boolean No If set to true, the response includes both updated caches and new caches created for the first time.
updateCacheMax integer No The maximum number of seconds that a cache update is considered a price change. By default, this is set to 24 hours (86400 seconds). If the updated cache exceeds this value, it is treated as a new cache and not a change in availability. The higher the value, the more availabilities will appear in the listing. If your cache is only a few hours old, you should adjust this value accordingly to process fewer caches.

The parameters must be sent by POST protocol, for example in linux, curl -X POST https://fresh.cache.veturis.com:/yourEndPoint.php -d 'password=yourPassword' -d 'updateCacheMax=36000'

The all parameter additionally includes updated availabilities for which there was no previous quote. These can be significantly more, so it is recommended to use this option only in coordination with Veturis. With it, you can retrieve all cache updates from Veturis, including not only caches with price and availability changes but also new prices.

The updateCacheMax parameter limits how old a cache can be to be considered a price change.

Response Format

The API returns data in either JSON or XML format, depending on the request parameters.

JSON Response

By default, the response includes only updated caches in JSON format. Each line consists of two fields separated by a colon (:):

  1. Update Time: Time in seconds since the cache was last updated in Veturis. A value of 0 indicates the cache was created for the first time.
  2. Data: A JSON object containing cache details.

Example:

$ curl -X POST https://fresh.cache.veturis.com:/yourEndPoint.php      -d 'password=YOUR_PASSSWORD' -d 'updateCacheMax=3600'
1164:{"in":"2025-01-17","out":"2025-01-21","country":"ESP","occupancies":[{"rooms":1,"adults":3,"children":0,"ages":[]}],"hotel_list":["87205","212137","14777","26707","19527","83729","14772","14853","36109","131982","85683","85696","57502","31342","87202","22312","27432","85693","19535","14776","26697","23130","14846","24654","407474","71605","187483","27128","14717","14746","14674","14826","210398","14698","138154"]}
1169:{"in":"2025-01-17","out":"2025-01-21","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":1,"ages":["11"]}],"hotel_list":["14683","14800","14731","14797","27895","14716","14721","63250","14775","14860","14796","270722","14813","77785","146916"]}
485:{"in":"2025-03-26","out":"2025-03-30","country":"ARE","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["443380"]}
449:{"in":"2025-01-02","out":"2025-01-06","country":"SAU","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["220796"]}
2117:{"in":"2025-02-01","out":"2025-02-03","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]},{"rooms":1,"adults":3,"children":0,"ages":[]}],"hotel_list":["67458"]}
477:{"in":"2025-01-18","out":"2025-01-21","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["55412"]}
991:{"in":"2024-12-31","out":"2025-01-03","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["196502"]}
780:{"in":"2024-12-28","out":"2025-01-03","country":"ARE","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["57893"]}
1459:{"in":"2025-04-19","out":"2025-04-26","country":"ESP","occupancies":[{"rooms":1,"adults":1,"children":0,"ages":[]}],"hotel_list":["217014","13203","68889","13261","54753","13217","36059","35380","197345","13231","220882","65004","13282"]}
1439:{"in":"2025-06-23","out":"2025-06-26","country":"ESP","occupancies":[{"rooms":1,"adults":3,"children":1,"ages":["11"]}],"hotel_list":["14459"]}
2003:{"in":"2025-01-02","out":"2025-01-04","country":"ESP","occupancies":[{"rooms":1,"adults":1,"children":0,"ages":[]}],"hotel_list":["72048"]}
980:{"in":"2025-04-11","out":"2025-04-17","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["50404"]}
3379:{"in":"2025-03-27","out":"2025-03-30","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["55412"]}
2907:{"in":"2025-03-22","out":"2025-03-26","country":"CHN","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["65340","146317"]}
542:{"in":"2025-09-01","out":"2025-09-04","country":"MEX","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["16261","446152","416360","32180","73198","397067","396395","16243","24463","101370"]}
776:{"in":"2025-01-08","out":"2025-01-15","country":"ARE","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["57893"]}
383:{"in":"2025-05-22","out":"2025-05-24","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["23200"]}
2885:{"in":"2025-05-18","out":"2025-05-29","country":"ARG","occupancies":[{"rooms":1,"adults":3,"children":1,"ages":["2"]}],"hotel_list":["215727"]}
3400:{"in":"2025-01-10","out":"2025-01-13","country":"ESP","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["72605"]}
546:{"in":"2025-01-01","out":"2025-01-06","country":"ARE","occupancies":[{"rooms":1,"adults":2,"children":0,"ages":[]}],"hotel_list":["57893"]}
    

XML Response

If the asXML parameter is set to true, the second field of each line is an XML document. This document provides a precise cache query format for the Veturis system.

Example:

$ curl -X POST https://fresh.cache.veturis.com:/yourEndPoint.php      -d 'password=YOUR_PASSWORD'      -d 'asXML=true'
13209:<?xml version="1.0" encoding="UTF-8"?><SearchAvailabilityRQRQ version="2.0" language="ENG"><Request><Check_in_date>2025-06-02</Check_in_date><Check_out_date>2025-06-12</Check_out_date><Occupancy><Rooms>1</Rooms><Adults>2</Adults><Children>0</Children></Occupancy><HotelList>18030</HotelList><CountryCode>ESP</CountryCode><TimeLimit>0</TimeLimit></Request></SearchAvailabilityRQ>
24610:<?xml version="1.0" encoding="UTF-8"?><SearchAvailabilityRQ version="2.0" language="ENG"><Request><Check_in_date>2025-01-08</Check_in_date><Check_out_date>2025-01-11</Check_out_date><Occupancy><Rooms>1</Rooms><Adults>2</Adults><Children>0</Children></Occupancy><HotelList>165291</HotelList><CountryCode>CHN</CountryCode><TimeLimit>0</TimeLimit></Request></SearchAvailabilityRQ>
14435:<?xml version="1.0" encoding="UTF-8"?><SearchAvailabilityRQ version="2.0" language="ENG"><Request><Check_in_date>2025-07-18</Check_in_date><Check_out_date>2025-07-28</Check_out_date><Occupancy><Rooms>1</Rooms><Adults>3</Adults><Children>0</Children></Occupancy><HotelList>445184</HotelList><CountryCode>ESP</CountryCode><TimeLimit>0</TimeLimit></Request></SearchAvailabilityRQ>
39211:<?xml version="1.0" encoding="UTF-8"?><SearchAvailabilityRQ version="2.0" language="ENG"><Request><Check_in_date>2025-07-16</Check_in_date><Check_out_date>2025-07-26</Check_out_date><Occupancy><Rooms>1</Rooms><Adults>3</Adults><Children>0</Children></Occupancy><HotelList>443306/446495</HotelList><CountryCode>ARE</CountryCode><TimeLimit>0</TimeLimit></Request></SearchAvailabilityRQ>
29188:<?xml version="1.0" encoding="UTF-8"?><SearchAvailabilityRQ version="2.0" language="ENG"><Request><Check_in_date>2025-03-31</Check_in_date><Check_out_date>2025-04-05</Check_out_date><Occupancy><Rooms>1</Rooms><Adults>2</Adults><Children>0</Children></Occupancy><HotelList>17942</HotelList><CountryCode>ISR</CountryCode><TimeLimit>0</TimeLimit></Request></SearchAvailabilityRQ>
6916:<?xml version="1.0" encoding="UTF-8"?><SearchAvailabilityRQ version="2.0" language="ENG"><Request><Check_in_date>2025-09-12</Check_in_date><Check_out_date>2025-09-16</Check_out_date><Occupancy><Rooms>1</Rooms><Adults>2</Adults><Children>0</Children></Occupancy><HotelList>401628</HotelList><CountryCode>PRT</CountryCode><TimeLimit>0</TimeLimit></Request></SearchAvailabilityRQ>
    

How to Use the API

The API should be called with high frequency, for example, every second. The API maintains a queue of the most recently updated caches. Once you retrieve the updated caches from Veturis, launch the availability queries to Veturis SearchAvailabilityRQ API to get new quotes.

Notes for Implementation

The following examples demonstrate how to implement a continuous loop to retrieve requests and process them in parallel using the API. Select the desired programming language:

<?php
...
while (true) {
	      $requests = getRequestsFromFreshCache($initialApiUrl, $freshCachePassword, $asXml, $secondsUpdateCacheMax);
	      processRequestsInParallel($requests, $user, $pass, $agencyUser, $agencyPassword, $veturisUrl);
}
?>

PHP Example

<?php
/************************************************
 * EXAMPLE SCRIPT IN PHP (ALL IN ENGLISH)
 ************************************************/

/**
 * 0) Configuration for the request to fresh cache
 */
$initialApiUrl     = "https://fresh.cache.veturis.com:/yourEndPoint.php";
$freshCachePassword  = "password_freshcache"// Replace with your actual password
$asXml             = "true";           // We want the response in XML format
$secondsUpdateCacheMax = 3600*6;  //We want only caches that have changed price in last 24h


/**
 * 1) Configuration for the request to Veturis SearchAvailability API, you already have this keys
 */
$veturisUrl       = "https://xmlservices.veturis.com/xmlWebServices.php";
$user             = "Veturis_api_user";        // Replace with your real user
$pass             = "user_pass";    // Replace with your real password
$agencyUser       = "agencyUser_name";      // Replace with your real agency user
$agencyPassword   = "agencyUser_password";  // Replace with your real agency password

/**
 * 2) Function to fetch and parse requests from tour_end_point.php
 *    Each line in the response has the format:
 *    ":"
 */
function getRequestsFromFreshCache($apiUrl, $password, $asXml, $secondsUpdateCacheMax) {
    // Prepare POST fields
    $postFields = [
        'password' => $password,
        'asXML'    => $asXml,
        'updateCacheMax'    => $secondsUpdateCacheMax
    ];

    // Initialize cURL
    $ch = curl_init($apiUrl);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Execute and retrieve the response
    // Each line looks like: "8132:"
    $response = curl_exec($ch);
    curl_close($ch);
    //printf($response); //For debugging reason comment it in production

    // Separate the response by lines
    $lines = explode("\n", $response);

    // Parse each line to extract the cache seconds and the XML
    $requests = [];
    foreach ($lines as $line) {
        $line = trim($line);
        if ($line === '') {
            continue; // Skip empty lines
        }

        // Use explode with limit=2 to split at the first colon only
        $parts = explode(':', $line, 2);
        if (count($parts) < 2) {
            continue; // Not well-formed, ignore
        }

        $cacheSeconds = trim($parts[0]);
        $xml = trim($parts[1]);

        $requests[] = [
            // First parameter is not an ID; it represents
            // how many seconds the cache was freshly updated.
            'cache_seconds' => $cacheSeconds,
            'xml'           => $xml
        ];
    }

    return $requests;
}

/*
 * Process the given requests in parallel (150 at a time),
 * handling each response as soon as it becomes available.
 *
 * @param array  $requests         An array of requests; each request must have 'xml'
 * @param string $user             Veturis user
 * @param string $password         Veturis password
 * @param string $agencyUser       Agency user
 * @param string $agencyPassword   Agency password
 * @param string $veturisUrl       URL endpoint for Veturis
 */
function processRequestsInParallel($requests, $user, $password, $agencyUser, $agencyPassword, $veturisUrl)
{
    // Break the array of requests into chunks of 150
    $chunks = array_chunk($requests, 50);

    foreach ($chunks as $chunk) {
        // Initialize the multi_curl handle
        $multiCurl = curl_multi_init();

        // Keep track of all cURL handles so we can manage them
        $curlHandles = [];

        // Create a cURL handle for each request
        foreach ($chunk as $request) {
            $xmlRQ = $request['xml'];

            // Prepare the POST data
            $postFields = [
                'xmlRQ'          => $xmlRQ,
                'user'           => $user,
                'password'       => $password,
                'agencyUser'     => $agencyUser,
                'agencyPassword' => $agencyPassword
            ];

            // Initialize a single cURL handle
            $ch = curl_init($veturisUrl);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            // Add the handle to the multi handle
            curl_multi_add_handle($multiCurl, $ch);
            $curlHandles[] = $ch;
        }

        // Track whether there are still active transfers
        $active = null;

        // Execute all requests in parallel, but process as soon as each one finishes
        do {
            // Run the multi_curl
            $mrc = curl_multi_exec($multiCurl, $active);

            // Check if there is any completed request
            while ($info = curl_multi_info_read($multiCurl)) {
                if ($info['msg'] === CURLMSG_DONE) {
                    // One of the requests has finished
                    $finishedHandle = $info['handle'];

                    // Get the response from the finished handle
                    $response = curl_multi_getcontent($finishedHandle);

                    // ---------------------------------------------
                    // Here is where you can:
                    //   - Save $response to a database
                    //   - Cache it
                    //   - Process or parse the response
                    //   - etc.
                    // ---------------------------------------------
                    // Example:
                    // echo "Response:\n$response\n\n";

                    // Remove the handle from the multi handle
                    curl_multi_remove_handle($multiCurl, $finishedHandle);
                    // Close the finished handle
                    curl_close($finishedHandle);
                }
            }

            // If there are still active handles, wait for activity
            if ($active) {
                curl_multi_select($multiCurl);
            }

        } while ($active && $mrc == CURLM_OK);

        // At this point, all handles in this chunk are done
        // (because we remove each as it finishes)
        echo "[INFO] " . count($chunk) . " requests processed.\n";

        // Close the multi-curl
        curl_multi_close($multiCurl);
    }
}

/**
 * 4) Main loop (continuous example to Veturis SearchAvailability)
 */
while (true) {
    // a) Retrieve requests from tour_end_point.php
    printf("[INFO] Quering FreshCache.\n");
    $elapsedTime=microtime(true);
    $requests = getRequestsFromFreshCache($initialApiUrl, $freshCachePassword, $asXml,$secondsUpdateCacheMax);

    if (empty($requests)) {
        echo "[INFO] No requests received. Waiting 1 seconds...\n";
        sleep(1);
        continue;
    }
    else{
            printf("[INFO] ". count($requests). " caches from FreshCache.\n");
    }
    processRequestsInParallel($requests, $user, $pass, $agencyUser, $agencyPassword, $veturisUrl);
    echo "[INFO] Iteration completed in ". (microtime(true)-$elapsedTime) ." seconds.\n";
}
?>