.. meta:: :description: Wired Zak API read guests :keywords: api, pms, zak, kapi, booking, bookings, reservation, reservations, guest, guests Zak API to read/write reservations details ****************************************** | These APIs allow you to read/write the reservations data of a zak property. .. _123456: ../kapi/introduction.html#authentication | On each examples `123456`_ is used as **api-key** which is sent as *user*. A Reservation ============= A reservation is a data structure composed of the following fields: .. table:: :widths: auto +--------------------------+-----------------------------------------------------------------------------------------+ | **Field name** | **Description** | +==========================+=========================================================================================+ | *id* | Id of the reservation | +--------------------------+-----------------------------------------------------------------------------------------+ | *rcode* | Reservation code of the form XY-0001 | +--------------------------+-----------------------------------------------------------------------------------------+ | *rooms* | A list of rooms | +--------------------------+-----------------------------------------------------------------------------------------+ | *status* | Status of the reservation | +--------------------------+-----------------------------------------------------------------------------------------+ | *price* | A data structure containing information regarding the price | +--------------------------+-----------------------------------------------------------------------------------------+ | *payment* | A data structure containing information regarding the payment | +--------------------------+-----------------------------------------------------------------------------------------+ | *board* | type of board of the reservation | +--------------------------+-----------------------------------------------------------------------------------------+ | *agency* | id of the agency through which the reservation has been made | +--------------------------+-----------------------------------------------------------------------------------------+ | *booker* | id of the booker | +--------------------------+-----------------------------------------------------------------------------------------+ | *corporate* | id of the corporate through which the reservation has been made | +--------------------------+-----------------------------------------------------------------------------------------+ | *created* | creation date of the reservation | +--------------------------+-----------------------------------------------------------------------------------------+ A room is structured as following: .. table:: :widths: auto +--------------------------+-----------------------------------------------------------------------------------------+ | **Field name** | **Description** | +==========================+=========================================================================================+ | *dfrom* | Starting date | +--------------------------+-----------------------------------------------------------------------------------------+ | *dto* | Ending date | +--------------------------+-----------------------------------------------------------------------------------------+ | *id_zak_room* | id of the room | +--------------------------+-----------------------------------------------------------------------------------------+ | *id_zak_room_type* | id of the room type | +--------------------------+-----------------------------------------------------------------------------------------+ | *customers* | A data structure containing the ids of the customers related to the reservation | +--------------------------+-----------------------------------------------------------------------------------------+ | *occupancy* | A data structure containing information regarding occupancy | +--------------------------+-----------------------------------------------------------------------------------------+ Fetch one reservation ===================== .. include:: ../kapi/pro_api_info.rst | | This method will return information regarding a specific reservation of a given property. .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/fetch_one_reservation | Usage example ------------- At least one of the following parameters is required: .. table:: :widths: auto +--------------------------+-----------------------------------------------------------------------------------------+ | **Field name** | **Description** | +==========================+=========================================================================================+ | *id* | reservation id | +--------------------------+-----------------------------------------------------------------------------------------+ | *hcode* | reservation code of the form (XY-0001) | +--------------------------+-----------------------------------------------------------------------------------------+ .. tabs:: .. code-tab:: bash curl $ curl --location --request POST 'https://kapi.wubook.net/kp/reservations/fetch_one_reservation' \ --header 'x-api-key: wb_yyyyyyyyyyy' \ --header 'x-api-provider-key: kp_xxxxxxxxx' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'rcode=BS-0003' .. code-tab:: py >>> import requests >>> headers = {'x-api-key':'123456', 'x-api-provider-key':654321} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/fetch_one_reservation', headers = headers, data = data) >>> print(response.text) | Response Example ---------------- .. code-block:: shell $ { "data": { "id": 1758, "id_human": "BS-0003", "booker": 90706, "country": "DE", "status": "Confirmed", "board": "nb", "created": "12/11/2021", "agency": null, "corporate": null, "price": { "rooms": { "amount": 7195.909090909092, "vat": 719.5909090909087, "total": 7915.5, "discount": 0, "currency": "EUR" }, "extras": { "amount": 0, "vat": 0, "total": 0, "discount": 0 }, "meals": { "amount": 0, "vat": 0, "total": 0, "discount": 0 }, "total": 7951.5 }, "payment": { "amount": 0, "currency": "EUR" }, "taxes": { "rsrv_tax": { "currency": "EUR", "amount": 0, "vat": 0, "vat_rate": 0, "total": 0, "discount": 0 }, "currency": "EUR", "room_tax": { "amount": 36, "total": 36, "vat": 0, "vat_rate": 0 }, "total": 36 }, "rooms": [ { "id_zak_room": null, "id_zak_room_type": 1, "dfrom": "12/11/2021", "dto": "15/11/2021", "occupancy": { "adults": 2, "teens": 0, "children": 0, "babies": 0 }, "customers": [ { "arrived": "15/11/2021", "departed": "15/11/2021", "id": 90706 } ] }, { "id_zak_room": null, "id_zak_room_type": 7, "dfrom": "12/11/2021", "dto": "15/11/2021", "occupancy": { "adults": 4, "teens": 0, "children": 0, "babies": 0 }, "customers": [] }, { "id_zak_room": null, "id_zak_room_type": 3, "dfrom": "13/11/2021", "dto": "18/11/2021", "occupancy": { "adults": 2, "teens": 0, "children": 0, "babies": 0 }, "customers": [] }, { "id_zak_room": null, "id_zak_room_type": 3, "dfrom": "13/11/2021", "dto": "18/11/2021", "occupancy": { "adults": 2, "teens": 0, "children": 0, "babies": 0 }, "customers": [] } ] } } | Create a reservation ==================== | Used to insert a reservation .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/new | Usage example ------------- The information is sent with an unique parameter, containing a json structure: .. table:: :widths: auto +--------------------------+-----------------------------------------------------------------------------------------+ | **Field name** | **Description** | +==========================+=========================================================================================+ | *params* | Json Structure | +--------------------------+-----------------------------------------------------------------------------------------+ The Json Structure has the following mandatory fields: .. table:: :widths: auto +--------------------------+-----------------------------------------------------------------------------------------+ | **Field name** | **Description** | +==========================+=========================================================================================+ | *arrival* | Arrival (european format 21/12/2121) | +--------------------------+-----------------------------------------------------------------------------------------+ | *depature* | Departure (european format 21/12/2121) | +--------------------------+-----------------------------------------------------------------------------------------+ | *customer* | As an object: {'name': Name, 'surname': surname} (and optionally email and phone) | +--------------------------+-----------------------------------------------------------------------------------------+ It is also mandatory to specify rooms and/or products. At least specify rooms or products (specifying both still possible): .. table:: :widths: auto +--------------------------+-----------------------------------------------------------------------------------------+ | **Field name** | **Description** | +==========================+=========================================================================================+ | *rooms* | A list of rooms (each room being a dict-like object) | +--------------------------+-----------------------------------------------------------------------------------------+ | *products* | A list of products (each product being a dict-like object) | +--------------------------+-----------------------------------------------------------------------------------------+ About rooms: you can specify the room type, the phisical room or both information. .. tabs:: .. code-tab:: bash curl $ curl --location --request POST 'https://192.168.1.225:11512/kp/reservations/new' \ --header 'x-api-key: wb_90dc1e88-2f0c-11eb-acd8-1150d7962d48' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'params={"arrival": "10/10/2022", "departure": "11/10/2022", "customer": {"name": "Name", "surname": "Surname"}, "rooms": [{"room": 159, "room_type": 107, "price": 100, "currency": "EUR"}], "products": [{"product": 329, "price": 101, "currency": "EUR"}]}' .. code-tab:: py >>> import requests >>> import json >>> headers = {'x-api-key':'123456'} >>> room= {'room': 123, 'room_type': 321, 'price': 100, 'currency': 'EUR'} >>> rooms= [room] >>> prod= {'product': 999, 'price': 110, 'currency': 'EUR'} >>> prods= [prod] >>> cust= {'name': 'Bat', 'surname': 'Man', 'email': 'bat@gotham.us', 'phone': '3333'} >>> arv= '21/10/2021' >>> dep= '22/10/2021' >>> params= {'arrival': arv, 'departure': dep, 'customer': cust, 'rooms': rooms, 'products': prods} >>> data= {'params': json.dumps(params)} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/new', headers = headers, data = data) >>> print(response.text) | Response Example ---------------- .. code-block:: shell $ { "data": { "id": XY-0001, } | Fetch reservations ================== .. include:: ../kapi/pro_api_info.rst | | This method will return a list of reservations .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/fetch_reservations | Usage example ------------- Input fields are not necessary, nevertheless a data structure containing filtering options can be provided .. table:: :widths: auto +--------------------------+-----------------------------------------------------------------------------------------+ | **Type of filters** | **Description** | +==========================+=========================================================================================+ | *created* | Reservations created in a range of dates | +--------------------------+-----------------------------------------------------------------------------------------+ | *arrival* | Reservation with arrival date in a range of dates | +--------------------------+-----------------------------------------------------------------------------------------+ | *departure* | Reservation with departure date in a range of dates | +--------------------------+-----------------------------------------------------------------------------------------+ | *pager* | Paging options - Limit can be a value in [8, 16, 32, 64], offset can be any integer | +--------------------------+-----------------------------------------------------------------------------------------+ .. code-block:: shell ${'filters':{ 'created': {'from': '10/10/2020', 'to':'01/02/2021'}, 'arrival': {'from': '17/12/2020', 'to': '11/01/2021'}, 'departure': {'from': '10/02/2021', 'to': '12/03/2021'}, 'pager': {'limit': 8, 'offset': 0} } } **filters** must be passed as JSON. .. tabs:: .. code-tab:: bash curl $ curl --location --request POST 'https://kapi.wubook.net/kp/reservations/fetch_reservations' \ --header 'x-api-key: wb_xxxxxxxxxxxxx' \ --header 'x-api-provider-key: kp_yyyyyyyyyyyy' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'filters={"created": {"from": "20/08/2021", "to": "30/09/2021"}, "arrival": {"from": "", "to": ""}}' .. code-tab:: py >>> import requests >>> headers = {'x-api-key':'123456', 'x-api-provider-key':654321} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/fetch_reservations', headers = headers, data = data) >>> print(response.text) | Response example ---------------- This API returns a list of reservations. | Fetch today reservations ======================== .. include:: ../kapi/pro_api_info.rst | This method will return a list of reservations .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/fetch_today_reservations | Usage example ------------- Input fields are not necessary. .. tabs:: .. code-tab:: bash curl $ curl --location --request POST 'https://kapi.wubook.net/kp/reservations/fetch_today_reservations' \ --header 'x-api-key: wb_yyyyyyyyyyy' \ --header 'x-api-provider-key: kp_xxxxxxxxx' .. code-tab:: py >>> import requests >>> headers = {'x-api-key':'123456', 'x-api-provider-key':654321} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/fetch_reservations', headers = headers) >>> print(response.text) Checkin/out =========== This section describes methods to execute check-in / check-out actions on a given reservation. .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/do_checkin .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/do_checkout | Usage example ------------- Following parameters can / must be used in order to use this call .. table:: :widths: auto +--------------------------+-----------------------------------------------------------+----------------------------------------+ | **Field name** | **Description** | **Mandatory** | +==========================+===========================================================+========================================+ | *reservation_id* | reservation id | yes, if not human_code | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *human_code* | reservation code of the form (XY-0001) | yes, if not id | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *room_customer_ids* | list of reservation room customers id's | No | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *all* | str to check-in(out) all the customers in a reservation | No | | | (any string is ok, 'x' e.g ) | | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | .. tabs:: .. code-tab:: bash curl $ curl --location --request POST 'https://kapi.wubook.net/kp/reservations/do_checkin' \ --header 'x-api-key: wb_yyyyyyyyyyy' \ --header 'x-api-provider-key: kp_xxxxxxxxx' --data-urlencode 'reservation_ireservation_id=599' \ --data-urlencode 'all='\''true'\ .. code-tab:: py >>> import requests >>> headers = {'x-api-key':'123456', 'x-api-provider-key':'654321'} >>> body = {'reservation_id':'123', 'all':'x'} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/do_checkin', headers = headers, data = body) >>> print(response.text) | Response example ---------------- .. code-block:: shell ${"data": { "success": "true" } | .. code-block:: shell ${ "error": "the error" } | Undo Checkin/out ================ This section describes methods to revert check-in / check-out actions on a given reservation. .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/undo_checkin .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/undo_checkout | Usage example ------------- Following parameters can / must be used in order to use this call .. table:: :widths: auto +--------------------------+-----------------------------------------------------------+----------------------------------------+ | **Field name** | **Description** | **Mandatory** | +==========================+===========================================================+========================================+ | *reservation_id* | reservation id | yes, if not human_code | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *human_code* | reservation code of the form (XY-0001) | yes, if not id | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | .. tabs:: .. code-tab:: bash curl $ curl --location --request POST 'https://kapi.wubook.net/kp/reservations/undo_checkin' \ --header 'x-api-key: wb_yyyyyyyyyyy' \ --header 'x-api-provider-key: kp_xxxxxxxxx' --data-urlencode 'reservation_id=599' \ --data-urlencode 'all='\''true'\ .. code-tab:: py >>> import requests >>> headers = {'x-api-key':'123456', 'x-api-provider-key':'654321'} >>> body = {'reservation_id':'123', 'all':'x'} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/undo_checkin', headers = headers, data = body) >>> print(response.text) | Response example ---------------- .. code-block:: shell ${"data": { "success": "true" } | .. code-block:: shell ${ "error": "the error" } | Add Customer ============ This section describes how to add customer to a given reservation. .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/add_customer | Usage example ------------- Following parameters can / must be used in order to use this call .. table:: :widths: auto +--------------------------+-----------------------------------------------------------+----------------------------------------+ | **Field name** | **Description** | **Mandatory** | +==========================+===========================================================+========================================+ | *reservation_id* | reservation id | yes, if not human_code | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *human_code* | reservation code of the form (XY-0001) | yes, if not reservation_id | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *reservation_room_id* | reservation room id | yes | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *custdata* | json object containing customer to add | yes | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | *docdata* | json object containing document to add | yes | +--------------------------+-----------------------------------------------------------+----------------------------------------+ | A customer data is .. table:: :widths: auto +----------------------------+-----------------------------------------------------------+----------------------------------------+ | **Field name** | **Description** | **Mandatory** | +============================+===========================================================+========================================+ | *name* | str | yes | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *surname* | str | yes | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *country* | str ('IT', 'GB', 'ES'..) | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *birth_contry* | str ('IT', 'GB', 'ES'..) | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *residence_country* | str ('IT', 'GB', 'ES'..) | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *birthday* | str ( '10/01/1993' ) | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *phone* | str | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *zipcode* | str | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *address* | str | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *city* | str | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *birth_city* | str | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *email* | str | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *gender* | str ('m', 'f', 'x') | no | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | A docdata is .. table:: :widths: auto +----------------------------+-----------------------------------------------------------+----------------------------------------+ | **Field name** | **Description** | **Mandatory** | +============================+===========================================================+========================================+ | *doc_type* | str (see doc types in syms) | yes | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *doc_country* | str ('italy', 'spain' ...) | yes | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *doc_number* | str | yes | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *doc_issue* | str | yes | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | *doc_expiry* | str | yes | +----------------------------+-----------------------------------------------------------+----------------------------------------+ | .. tabs:: .. code-tab:: bash curl $ curl --location --request POST 'https://kapi.wubook.net/kp/reservations/add_customer' \ --header 'x-api-key: wb_yyyyyyyyyyy' \ --header 'x-api-provider-key: kp_xxxxxxxxx' --data-urlencode 'id=599' \ --data-urlencode 'custdata={}'\ --data-urlencode 'all='\''true'\ .. code-tab:: py >>> import requests >>> import json >>> headers = {'x-api-key':'123456', 'x-api-provider-key':'654321'} >>> custdata = {...} >>> custdata = json.dumps(custdata) >>> body = {'id':'123', 'custdata': custdata} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/undo_checkin', headers = headers, data = body) >>> print(response.text) | Response example ---------------- .. code-block:: shell ${"data": { "customer_id": "10", "reservation_room_customer_id": "15", } | .. code-block:: shell ${ "error": "the error" } | Meal ==== A meal is a data structure having the following fields .. table:: :widths: auto +----------------+-------------------------------------------+-------------------------------------------------+ | **Field name** | **Description** | **subf-ields** | +================+===========================================+=================================================+ | id | id of the meal | | +----------------+-------------------------------------------+-------------------------------------------------+ | dates | structure containing dates information | day, created | +----------------+-------------------------------------------+-------------------------------------------------+ | meal_info | structure containing meal information | mnumber, mtype, times | +----------------+-------------------------------------------+-------------------------------------------------+ | price | structure containing costs information | amount, currency, discount, total, vat, vat_rate| +----------------+-------------------------------------------+-------------------------------------------------+ | Sub-fields description .. table:: :widths: auto +------------------+---------------------------+--------------------------------------+ | **field** | **Type** | **Description** | +------------------+---------------------------+--------------------------------------+ | day | date (dd/mm/yyyy) | day on which the meal was eaten | +------------------+---------------------------+--------------------------------------+ | created | date (dd/mm/yyyy) | creation date on Zak | +------------------+---------------------------+--------------------------------------+ | mnumber | integer | number of meals | +------------------+---------------------------+--------------------------------------+ | mtype | string ("b", "l" or "d" ) | Breakfast, lunch or dinner | +------------------+---------------------------+--------------------------------------+ | times | integer | number of repetitions for this meal | +------------------+---------------------------+--------------------------------------+ | amount | float | amount | +------------------+---------------------------+--------------------------------------+ | currency | string | currency of the amount | +------------------+---------------------------+--------------------------------------+ | discount | float | discount | +------------------+---------------------------+--------------------------------------+ | total | float | total | +------------------+---------------------------+--------------------------------------+ | vat | float | vat | +------------------+---------------------------+--------------------------------------+ | vat_rate | int | vat percentage | +------------------+---------------------------+--------------------------------------+ Meal example ------------ .. code-block:: shell ${"data": { "id": 34, "dates": { "created": "27/01/2021", "day": "25/01/2021" }, "meal_info": { "mnumber": 1, "mtype": "l", "times": 1 }, "price": { "amount": 19.0, "currency": "EUR", "discount": 0.0, "total": 19.0, "vat": 0.0, "vat_rate": 0 } }, } Get Meals ========= .. include:: ../kapi/pro_api_info.rst | | This function will return a list of meals related to a given reservation .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/get_meals | Usage example ------------- Only **reservation id** is required to use this API. .. tabs:: .. code-tab:: bash curl $ curl -L -X POST 'https://kapi.wubook.net/kp/reservations/get_meals' -H 'x-api-key: 123456' -H 'x-api-provider-key: 654321' -d 'id=47' .. code-tab:: py >>> import requests >>> headers = {'x-api-key':'123456', 'x-api-provider-key':654321} >>> data = {'id': 1} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/get_meals', headers = headers, data = data) >>> print(response.text) Response example ---------------- .. code-block:: shell ${"data": [ {"id": 34 . . },{"id": 35 . . }, {}, {} ] | Add Meal ======== .. include:: ../kapi/pro_api_info.rst | | This API can be used to add a meal to a given reservation .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/add_meal | Usage example ------------- To use this API one must provide several different parameters .. table:: :widths:auto +-----------+--------------------------------------------+------------+-------------------------------------------------------+ | **Field** | **Description** | **Type** | **Sub-fields** | +===========+============================================+============+=======================================================+ | id | reservation id | int | | +-----------+--------------------------------------------+------------+-------------------------------------------------------+ | meal | data structure | JSON | price, mtype, mnumber, times, day, rooms, custs | +-----------+--------------------------------------------+------------+-------------------------------------------------------+ .. tabs:: .. code-tab:: bash curl $ curl -L -X POST 'https://kapi.wubook.net/kp/reservations/add_meal' -H 'x-api-key: 123456' -H 'x-api-provider-key: 654321' -d 'id=47' -d 'meal'='{}' .. code-tab:: py >>> import requests >>> import json >>> headers = {'x-api-key':'123456', 'x-api-provider-key':654321} >>> meal = {'theconfig':mealconfig} >>> json.dumps(meal) >>> data = {'id': 1, 'meal': meal} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/add_meal', headers = headers, data = data) >>> print(response.text) Response example ---------------- .. code-block:: shell ${ "data": 1 } | Delete Meal =========== | This API will allow you to delete a meal from zak. .. code-block:: html Url: https://kapi.wubook.net/kp/reservations/del_meal | Usage example ------------- To use this API only two parameters are mandatory: reservation id, namely **id**, and the meal id, **fmid**. .. tabs:: .. code-tab:: bash curl $ curl -L -X POST 'https://kapi.wubook.net/kp/reservations/del_meal' -H 'x-api-key: 123456' -H 'x-api-provider-key: 654321' -d 'id=47' -d 'fmid=1' .. code-tab:: py >>> import requests >>> headers = {'x-api-key':'123456', 'x-api-provider-key':'654321'} >>> data = {'id': 1, 'fmid':1} >>> response= requests.post('https://kapi.wubook.net/kp/reservations/del_meal', headers = headers, data = data) >>> print(response.text) Response example ---------------- .. code-block:: shell ${ "data": 1:.. warning:: } |