Home Features Pricing Contact Login

REST API

Get availability

POST
https://camping.care/api/v1/accommodations/id/availability

Authentication: API Key

Get availability information about a specific Accommodation between an arrival and a departure date

Parameters

Replace [id] in the endpoint URL by the accommodation id, for example: "https://camping.care/api/v1/accommodations/2/availability".

The specific id from a accommodation can be get by the function Get accommodations.
arrival
Date
Required - The arrival date on which the availability is based on in the format yyyy-mm-dd
departure
Date
Required - The departure date on which the availability is based on in the format yyyy-mm-dd

Response

201
application/json; charset=utf-8
count
Integer
The total number of free places within the given period for this accommodation

Example


/*
* Example get accommodation - How to get accommodation information from the Camping.care API
* https://camping.care/developer/accommodations/get_availability
*/


try {


    /*
    * Initialize the Camping.care API SDK with your API key.
    *
    * See: https://camping.care/settings/api
    */

    require_once dirname(__FILE__) . '/../../src/campingcare/Autoloader.php';

    $campingcare = new campingcare_api ;
    $campingcare->set_api_key('YOUR API KEY');

    /*
    * Set your accommodation id. It can be found by using the function get_accommodations 
    * http://camping.care/developer/accommodations/get_accommodations
    */

    $id =  37 ; // Accommodation ID (required)

    /*
    * Parameters:
    *   arrival             Arrival date for the availability (required)
    *   departure           Departure date for the availability (required)
    *   places              If set it returns the available places, if this parameter is not set you get the availability count only for this accommodation (optional)
    *   inactive_places     If set it includes the inactive places in the results (optional)
    *
    */

    $data = array();
    $data['arrival'] = "2018-06-10" ;
    $data['departure'] = "2018-06-17" ;
    $data['places'] = 1;
    $data['inactive_places'] = 0;

    /*
     * All data is returned in a availbility count, if requested also the places are returned in a array of place objects
     * The structure can be found here: https://camping.care/developer/accommodations/get_availability
     */
    $availability = $campingcare->get_availability($id, $data);

    /*
    * In this example we print the data in json format on the page
    */
    echo "GET availability between dates from an Accommodation";
    echo "
";
    echo json_encode($availability, JSON_PRETTY_PRINT);
    echo "
"; } catch (Exception $e) { echo "API call failed: " . htmlspecialchars($e->getMessage()); }
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using campingcare;
using Newtonsoft.Json.Linq;


namespace campingcare_csharp_sdk_tests
{
    public static class availability
    {

        /*
        * Example get accommodation - How to get accommodation information from the Camping.care API
        * https://camping.care/developer/accommodations/get_availability
        */

        public static async void get_availability()
        {
            try
            {
                Console.WriteLine("*************************************");
                Console.WriteLine("***      GET AVAILABILITY         ***");
                Console.WriteLine("*************************************");

                /*
                * Initialize the Camping.care API SDK with your API key.
                *
                * See: https://camping.care/settings/api
                */

                campingcare_api camping_care = new campingcare_api();
                camping_care.set_api_key("YOUR API KEY");

                /*
                * Set your accommodation id. It can be found by using the function get_accommodations 
                * http://camping.care/developer/accommodations/get_accommodations
                */
                int id = 123;

                /*
                * Parameters:
                *   arrival             Arrival date for the availability (required)
                *   departure           Departure date for the availability (required)
                *   places              If set it returns the available places, if this parameter is not set you get the availability count only for this accommodation (optional)
                *   inactive_places     If set it includes the inactive places in the results (optional)
                *
                */

                var send_data = new List>();

                send_data.Add(new KeyValuePair("arrival", "2018-03-01"));
                send_data.Add(new KeyValuePair("departure", "2018-03-02"));
                send_data.Add(new KeyValuePair("places", "1"));
                send_data.Add(new KeyValuePair("inactive_places", "0"));

                /*
                * All data is returned in a availbility count, if requested also the places are returned in a array of place objects
                * The structure can be found here: https://camping.care/developer/accommodations/get_availability
                */

                var data = await camping_care.get_availability(id, send_data);


                /*
                * In this example we print the oprions in json format on the page
                */

                JObject json = JObject.Parse(data.ToString());

                foreach (var pair in json)
                {
                    Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
                }

            }
            catch (Exception ex)
            {
                LogData(ex.Message);
            }
        }

        private static void LogData(string Message)
        {
            Console.WriteLine("Error: " + Message);
        }
    }
}



Response example

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{ "count": 22 }

Response Error

Returns an array with error information

230
application/json; charset=utf-8
code
Integer
The error code listed in a list below
message
String
The error message listed in a list below

Error Codes

1000
No valid API key
1007
No availability found
1008
No admin ID found
1009
Accommodation not found
1010
No rights for this accommodation
1011
Wrong arrival date: YYYY-MM-DD
1012
Wrong departure date
1013
Arrival date: YYYY-MM-DD is after departure date: YYYY-MM-DD
1014
Start date is in the past
0%
()

Cancel upload