Home Features Pricing Contact Login

REST API

Calculate Price

POST
https://camping.care/api/v1/reservations/calculate_price

Authentication: API Key

Get a price calculation of a specific accomodation and date. You need to have an accommodation id to get started. The specific id from a accommodation can be get by the function Get accommodations.

Parameters

accommodation_id
Integer
Required - The id of the accommodation
arrival
Date
Required - Arrival date for the calculation (YYYY-MM-DD)
departure
Date
Required - Departure date for the calculation (YYYY-MM-DD)
persons
String
Required - The number of persons for the calculation. If the administration is using age tables the number of persons should be a calculation of all persons in the age tables.
age_table_input
String
Required (if age tables are available) - The age table input of persons for the reservation. The age table input is a JSON string. It should be in this format:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[ 
	{ "id": AGE_TABLE_ID, "count": AGE_TABLE_AMOUNT }, 
	{ "id": AGE_TABLE_ID, "count": AGE_TABLE_AMOUNT } 
]


If the administration does not use any age tables this parameter is not required. Read more about age tables

Response

201
application/json; charset=utf-8
accommodation_id
Integer
The accommodation id of the calculation
arrival
Date
The arrival date for the calculated price
departure
Date
TThe departure date for the calculated price
total_price
Double
The total price for the calculation
accommodation_price
Double
The price for accommodation only
guest_price
Double
The price for extra guests only
accommodation_price_rows
Array
A array with the specific found prices. A calculation can combine different prices. Each price in the array contains information: - id: The price id for the given price
- name: The price it's name
- start_date: start date for the use of this price in this calculation
- end_date: The end date for the use of this price in this calculation
- type: The type for using in the reservation rows to determine if it is a accommodation, guest, tax or option price.
- price: The price for this accommodation.
- count: The number of times the price is used in this calculation
- total_price: The same as parameter "accommodation_price"
guest_price_rows
Array
A array with the specific found guest prices. A calculation can combine different guest prices. Each price in the array contains information: - id: The accommodation guest id for the given guest price
- name: The guest it's name
- type: The type for using in the reservation rows to determine if it is a accommodation, guest, tax or option price.
- price: The price for this accommodation.
- guest_type: Whether the guest price is of the type price or percentage
- guest_type_pro: Whether the guest price is pro night or week
- guest_type_amount: The price or percentage for the given "guest_type_pro"
- price_id: The price id this guest price is based on
- count: The number of times the price is used in this calculation
- total_price: The same as parameter "guest_price"

Example


/*
* Example calculate_price - How to get calculated price for a 
* specific accommodation between 2 dates from the Camping.care API
* https://camping.care/developer/reservations/calculate_price
*/


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 
    * https://camping.care/developer/reservations/calculate_price


    * Parameters:
    *   accommodation_id    Accommodation ID (required)
    *   arrival             Arrival date for the availability (required)
    *   departure           Departure date for the availability (required)
    *   persons             Number of persons. (required if no age tables)
    *   age_tables          Array of age table data check https://camping.care/developer/reservations/calculate_price (required if age tables are used in a park)
    *
    */

    $data = array();
    $data['accommodation_id'] = 37 ; // Accommodation ID (required)
    $data['arrival'] = "2018-06-10" ; //date YYYY-MM-DD
    $data['departure'] = "2018-06-17" ; //date YYYY-MM-DD

    $data["persons"] = "2"; // Number of persons for calcualtion

    /*
    * All data is returned as calculate price opject
    * The structure can be found here: https://camping.care/developer/reservations/calculate_price.
    */

    $calculated_price = $campingcare->calculate_price($data);

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

    echo "GET calculated price for a accommodation between dates";
    echo "
";
    echo json_encode($calculated_price, JSON_PRETTY_PRINT);
    echo "
"; } catch (Exception $e) { echo "API call failed: " . htmlspecialchars($e->getMessage()); }
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 calculate_price
    {
        /*
        * Example get calculate_price - How to get calculated price for a specific accommodation between 2 dates from the Camping.care API
        * https://camping.care/developer/accommodations/get_calculate_price
        */

        public static async void get_calculate_price()
        {
            try
            {
                Console.WriteLine("*************************************");
                Console.WriteLine("***      GET CALCULATE PRICE      ***");
                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");

                               /*
                * Parameters:
                *   accommodation_id    Accommodation id which can be found in the function get_accommodations https://camping.care/developer/accommodations/get_accommodations
                *   arrival             Arrival date for the availability (required)
                *   departure           Departure date for the availability (required)
                *   persons             Number of persons. (required if no age tables)
                *   age_tables          Array of age table data check https://camping.care/developer/accommodations/get_calculate_price (required if age tables are used in a park)
                *
                */

                var send_data = new List>();
                send_data.Add(new KeyValuePair("accommodation_id", "36"));
                send_data.Add(new KeyValuePair("arrival", "2018-03-01"));
                send_data.Add(new KeyValuePair("departure", "2018-03-10"));
                send_data.Add(new KeyValuePair("persons", "2"));

                /*
                * All data is returned as calculate price opject
                * The structure can be found here: https://camping.care/developer/accommodations/get_calculate_price.
                */
                var data = await camping_care.calculate_price(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

{
	"accommodation_id": 33,
    "arrival": "2018-04-10",
    "departure": "2018-04-16",
    "total_price": 72,
    "accommodation_price": 60,
    "guest_price": 12,
    "accommodation_price_rows": [
        {
            "id": 36,
            "name": "Pre Season",
            "start_date": "2018-04-10",
            "end_date": "2018-04-16",
            "type": "accommodation",
            "price": 10,
            "count": 6,
            "total_price": 60
        }
    ],
    "guest_price_rows": [
        {
            "id": "39",
            "name": "Extra Person",
            "amount": 1,
            "price": 12,
            "guest_type": "price",
            "guest_type_pro": "night",
            "guest_type_amount": "2",
            "price_id": 36,
            "count": 1
        }
    ]
}


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
1015
No price found
1016
No admin ID found
1017
Accommodation not found
1018
No rights for this accommodation
1019
Wrong arrival date
1020
Wrong departure date
1021
Arrival date: YYYY-MM-DD is after departure date: YYYY-MM-DD
1022
Start date is in the past
1023
Number of persons is not ok
1024
Number of persons is to much
0%
()

Cancel upload