Other connections

Other connections

Other


Introduction

In the Hotel Data Hub API, several numeric values are required, which serve to identify an item or element in Fideltour's database. We can deduce that if an item does not exist in the database, it must first be created in order to retrieve its identifier.

In this article, we will see how to create and retrieve different items externally to Hotel Data Hub. The methods we will use can be found in the swagger documentation. We will go through examples using the essential fields required for proper use of the API. Some items may include additional fields to provide more information — these are optional.

An item or element is understood as any data or group of data that may be used repeatedly during the use of our CRM. For example: a room type, the name of an agency, the name of a province, etc.

The base endpoint we will use for items is: https://app.hoteldatahub.io/api/v1/xxx/

Replacing "xxx" with the value specified by the API documentation in each case.

Use Cases:

Item management is practically essential for using the Hotel Data Hub API effectively, especially if we want to make the most of the platform and collect as much information as possible.
  • Creating new items: These will be persistently stored in Fideltour, thus helping to automate processes for accessing item data.
  • Retrieving item information: It will be necessary to access item data when we want to obtain its identifier, so that we can include it in our requests. This helps maintain data integrity and reduces the likelihood of errors in the requests.

Available methods:

  1. GET: Query of an item.
  2. POST: Insertion of a new item.



Examples:

Currently the different items of Fideltour and their methods are as follows:


Below are some examples of creating and displaying items in Fideltour.


Request (POST):

The following example shows a request to add a province in Hotel Data Hub.

In this case the requested field is "name", in others it will be "code", we will adapt the request to the method we are using.


Protocol: http/1.1

Method: post

Host/endpoint: https://app.hoteldatahub.io/api/v1/provinces/

Headers:

Content-type: application/json

Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Body: An example is added below.

  1. { {
  2. "name":"Balearic Islands",
  3. }



Answer(Post):

  1. { {
  2. "id":12345,
  3. "name":"Balearic Islands"
  4. }




Request (GET):

The following example shows a request for the information of the "junior-suite" room type information.


Protocol: http/1.1

Method: get

Host/endpoint: https://app.hoteldatahub.io/api/v1/room-types/?code=junior-suite

Headers:

  • Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

BODY: In this case, as a GET-type method, we do not include data in the body of the request, as they are included in the url.


Answer (GET):

We can verify that in the "id" field, the request has returned a number.

This number is the one that we must add in future requests, when you want to indicate that the room type is "junior-suite".


  1. { {
  2. "count":1 1 1,
  3. "next":null,
  4. "previous":null,
  5. "results":[ [ [
  6. { {
  7. "id":2541,
  8. "code":"junior-suite"
  9. }
  10. ]
  11. }