Get Availabilities

Example on how to Get Availabilities for a Villa

Post Request data

Name Type Description
villa_id Integer Id of the Villas you want to retrieve info on.

This sample code is written in PHP:


      $url = 'https://api.wthvillas.com/api/v1/availabilities';
      $data = array('villa_id' => "123");
      $data_string = $data;

      $curl = curl_init();
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_TIMEOUT, 30);
      curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Authorization: Bearer YourTokenGoesHere'
      );
      curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
      curl_setopt($curl, CURLOPT_URL, $url);
      curl_setopt($curl, CURLOPT_POST,count($data));
      curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);

      $response = curl_exec($curl);

      curl_close($curl);
      $returnData = json_decode($response, true);
      print_r($returnData);
  

Response example data

All Dates returned are available


      {
          "response": "success",
          "availabilities": [
              {
                  "availability_date": "2019-04-07"
              },
              {
                  "availability_date": "2019-04-08"
              },
              {
                  "availability_date": "2019-04-09"
              },
              {
                  "availability_date": "2019-04-10"
              },
              {
                  "availability_date": "2019-04-11"
              },
              {
                  "availability_date": "2019-04-12"
              },
              {
                  "availability_date": "2019-04-28"
              },
              {
                  "availability_date": "2019-04-29"
              },
              {
                  "availability_date": "2019-04-30"
              }
          ]
      }