Introduction

Introduction



Getting started







Introduction:


In this article, we show how to consult and use the HotelDataHub/Fideltour API through the Swagger platform.
There, we find the different endpoints (URLs) and the information that must be provided for each one to use the API correctly.
To access Swagger, we must visit the following link: https://app.hoteldatahub.io/swagger/

Once inside, to navigate through the methods and view the different endpoints, simply click on the desired section and all its information will be displayed.

When a section is expanded, all its methods and endpoints are shown. To make a request to the API, we always concatenate the URL https://app.hoteldatahub.io/api/v1/ with the desired endpoint.


Using the Swagger platform, in addition to providing all the information about the API, also offers mechanisms to make real requests and verify the functionality of each endpoint.

Authentication Token:

In order to use API requests, we need an authentication Token. The Token must be added in the header of each request.

  1. header= ={ {
  2. "content-type":"application/json,
  3. "Authorization":"Token_value Token"
  4. }

Important: replace "token_value" with the Token obtained in the endpointlogin/.

Request forLogin:

As we have just mentioned, in order to obtain a Token, we must make a POST request to the endpointhttps://app.hoteldatahub.io/api/v1/login. Here are the fields to be sent in the body of that request:

  1. body body= ={ {
  2. "username":"facilitated_per_HotelDataHub",
  3. "password":"password_for_HotelDataHub"
  4. }

This request can also be found in Swagger(https://app.hoteldatahub.io/swagger/#/login).

Important: Any Token expires 24 hours after obtaining. If an expired Token is used to make a request, the API returns an "401 Unauthorized" error.

Verify and refresh the token:

There are three ways to control the validity of the token and its soft drink:
  1. Use the token obtained in the login until a request returns a 401 error to us, at that time the login must be repeated to update the token and re-apply the request that returned to us a 401.
  2. Before each request, use the endpoint/token-verifyto confirm that the token is active. If it is not, we login to update it.
  3. Before 24 hours pass, use the endpoint/token-refreshto update the token and its expiration.



Use of Swagger:

In order to make requests through Swagger (except for the login request), we must log in by clicking on the button"Django Login", at the top of the page. A login form will appear, where we will enter the same credentials used to obtain theAuthentication Token.

Once we are logged in,we can make any request by clicking on the "Tryout" button and by filling out the information in the JSON file or the text fields for requests requesting it, the information in the text fields is added as a parameter.

Fields marked with a red asterisk(* * *) are mandatory.

When we have entered the information, click on "Execute" and the platform will show usthe server response in the following fields:
  • - Curl: Displays the information received by the server.
  • - Request url: Displays the endpoint where the request is sent.
  • - Server response:
  • - Code: server response code.
  • - Details: description of the response code.
  • - Response body: Replacement JSON file, this field includes a "Download" button, where we can download the file.
  • - Response headers: response header information.

For more information on the values to be sent or received in each endpoint, see the following documentation:
  • Contacts
  • Movements

Use Swagger without logging in:

In addition, we can make requests through Swagger using a valid Token. As always, we get the Token through the login request, and to insert it into the Swagger session we click on the button"Authorize", next to the button"Django Login" mentioned in the previous paragraph.

Pressing that button opens the next window, where we can insert the Token and confirm it (green "Authorize" button)


Note: using Swagger in this way, whenever we update the page, we have to re-enter the Token.




    • Related Articles

    • 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 ...
    • Loyalty

      Loyalty Introduction: In this article we talk about API requests related to the Fideltour Loyalty module. The sections of the Swagger which include this information are: https://app.hoteldatahub.io/swagger/#/contacts ...
    • GDPR Consent

      GDPR Consent Introduction: In this article, we talk about API requests related to the mandatory consents of the General Data Protection Regulation (GDPR in English), and how to manage it in our contacts. - Create consents for a contact - List and ...
    • Motion management

      Movements Table of Contents Introduction Use cases Available methods Table of parameters Examples Petition (POST) Answer (POST) Petition (GET) Answer (GET) Petition (PATCH) Answer (PATCH) Introduction: In this article we talk about API requests ...
    • Contact management

      Contacts Introduction: In this article we talk about API requests related to Contacts. Create contact Update contact List and filter contacts The endpoint we use is:https://app.hoteldatahub.io/api/v1/contacts/and the Swagger section ...