Hotelian.com API (22.05.11)

Download OpenAPI specification:Download

Our postman workspace: Hotelian.com Postman Workspace

General

Our API is designed with having simplicity, scalability and speed in mind. In a broad sense, we have divided the documentation into five sections of "Authorization", "Search", Pre-book", "Booking", and "Static Content".

To begin using our API, you will need an api_key and an api_secret. If you do not posses these, contact our api sales team either through the website, or our email at api_support@hotelian.com.

The workflow of this API is as described in the chart below



To successfully make a reservation using our API, you need to follow these steps:

1) Search for multiple hotels

Search for multiple hotels using one of our endpoints: /city, /geo-nearby, /geo-box, or /hotel. Regardless of the endpoint you use, the search process is the same. For example, you can search for hotels in Paris using /city an Paris's id, or by including all the hotels in Paris in /hotel, or by using Paris's centroid in /geo-nearby. We'll return bookable prices available for each viable hotel.

For multi-hotel search methods, it's recommended to set best_price_only parameter to true (it's true by default) since it significantly reduces search time. By doing so, you will receive only one option for each hotel with the lowest price.

Note: In /city, all your codes should be inside the same country, and in /hotel, all your codes should be in the same city.

What is an Option? Each collection of one or more available rooms is referred to as an option in our API. Our search methods will return an array of options for every hotel. The number of rooms in each option will depend on your search request. For example, if you request one room, the resulting options will consist of one room each, and if you request two rooms, the resulting options will consist of two rooms each.

2) Get availabilities of a single hotel (no cache)

In order to get all the options and prices, you must search for a single hotel using /search/hotel and set the best_price_only parameter to false.

We recommend first searching for a city(or any other multi-hotel search methods described in #1), and once the user is interested in a specific hotel, search for the availabilities of that individual hotel to get the complete list of available options.

In other words, the only way that you can ensure you are getting all the prices and options of a hotel is to search it individually. Make sure you only do this after your user is interested in the hotel, since this is a technically expensive procedure.

3) Get-policies

Once the user chooses an option, you need to call /get-policies to update the prices and policies for your user. Make sure you don't call this endpoint before your user asks for the final step of the reservation. A free-cancellation option might become non-refundable and vice versa. If an option becomes unavailable (sold-out), it won't be included in the results; Make sure you handle this scenario accordingly.

What is a policy? We refer to cancellation penalty policies as a policy. These define the set of rules for each option's cancellation and the possible following refund.

4) Book

After calling /get-policies and refreshing the prices and policies for your user, you can call /book. In this step, you can provide a client-reference that you can later use to look up this reservation. Make sure you handle all errors and exceptions accordingly.

Note that you cannot book the same option twice.

At this point, your reservation could be done; You have to check the results.status in the response and act accordingly. A pending reservation must be checked every 10 minutes using GET /book/{id} to follow up on its new status, which can be either rejected, or confirmed. This process can take anywhere from 10 minutes up to hours depending on the case. We suggest you set up a scheduled task for these reservations.

You should note that the status might become rejected straightaway without going to pending at all. In this case, your balance will be refunded automatically and you can try booking other options, or other hotels.

Timeout: Make sure to set your timeout up to 120 seconds. This operation could take a while in some cases.

5) Reservation details

You can check the list of your bookings and filter them using GET /book, or check the details of a single booking in /book/{id}. Some reservations might have a pending status, and for these, you must check the details every 10 minutes to see if they change to confirmed or rejected.

6) Payments

If your account supports it, you must pay for a pay_later booking using PATCH /book/{id} before its initial deadline. Failure to do so will result in a canceled booking.

Note that you don't need to do this step if you call /book with pay_later=false.

7) Cancel

You can also cancel a confirmed booking if its check-in date has not yet been reached. According to the policies you received in /get-policies, you will receive a refund if any is applicable.

A cancellation can result in a cancellation pending status. In this case, a refund will not be possible until the case is investigated further.

Timeout: Make sure to set your timeout up to 120 seconds. This operation could take a while in some cases.



Postman API

To start using our API, Use our Postman workspace

You can also  

Authorization

To use our API, you'll need to include two headers in your HTTP requests: x-api-key and x-api-signature.

1) x-api-key:

This header should contain your API key, which you can obtain from Hotelian.com. Simply set it as the x-api-key HTTP header.

2) x-api-signature:

This header requires a bit more work. In addition to your API key, you'll also need your API secret and the current Unix time (in seconds). You must calculate a new x-api-signature value for each request you send.

The formula for calculating this header is: SHA256(SHA256(your_api_key + your_api_secret + current_unix_time))

Here are the steps to calculate the x-api-signature header:

  • Concatenate your API key, API secret, and the current Unix time in seconds.
  • Encode the resulting string twice using SHA256 hash method.
  • Set the resulting string as the x-api-signature HTTP header.

Some notes:

  • Do not commit your API secrets to your version control system (VCS) or Git: Version control systems are designed to remember changes, so if you commit your API key or secret, it will be almost impossible to remove them from the repository history. Instead, consider setting up environment variables in your programming language and store the secrets there. Also, make sure to add any files containing your secrets to your .gitignore file to prevent them from accidentally being committed.

  • Calculate your x-api-signature header for each request: This header is time-based and will become invalid within seconds of its creation. Therefore, you must calculate a new x-api-signature header for every request you send to our API.


2-2. PHP sample of x-api-signature generation

function generateAPISignature(string $api_key, string $api_secret): string
{
    return hash(
        'sha256',
        hash('sha256', $api_key . $api_secret . ((string) time()))
    );
}

2-3. Postman Pre-request script

// Set your api key in postman environment as `API-KEY`
// Set your api secret in postman environment as `SECRET`
//Begin UTC creation
var utcDate = Math.floor(new Date().getTime() / 1000);

//Begin Signature Assembly
var publicKey = pm.environment.get("API-KEY");
var privateKey = pm.environment.get("SECRET");

var assemble = (publicKey+privateKey+utcDate);

//Begin SHA-256 Encryption
hash = CryptoJS.SHA256((CryptoJS.SHA256(assemble).toString()))
encryption = (hash.toString(CryptoJS.enc.Hex));

var Header = require('postman-collection').Header;
pm.request.headers.add(new Header("X-API-key: " + pm.environment.get('API-KEY')));
pm.request.headers.add(new Header("X-API-Signature: " + encryption));

2-4. Real Example

current_unix_time = 1642429744

your_api_key = hotelian_api_usd

your_api_secret = CDSmQDeq6rTgCSr8GvSyQG7IV9NBNycU

cat  = hotelian_api_usdCDSmQDeq6rTgCSr8GvSyQG7IV9NBNycU1642429744

first_hash = eb45597bfb366bbcf3be4dc089f8a877fb25a514cf54dd28191cc053a45f0079

your_signature = 080e0d6cd1e438d33d63e18098d53caaf92392a741204440a7ef45a0f264a783
  1. Set your api key (in this example hotelian_api_usd) as the X-API-Key HTTP header in your request.
  2. Set the calculated signature (in this example080e0d6cd1e438d33d63e18098d53caaf92392a741204440a7ef45a0f264a783) as the X-API-Signature HTTP header in your request.

Search

Search for room availability of hotels within a selected period(check-in, check-out). Note that our search will return all the possible prices for every hotel. The currency of which the prices are returned in is the one set on your account.

Based On City

Search available hotels inside one or more cities.

Request Body schema: application/json

Details of search

check_in
required
string <date> (CheckIn) [ 8 .. 10 ] characters

Check-in date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. Must be within today and up to a year from now. You should not include time in this string.

check_out
required
string <date> (CheckOut) [ 8 .. 10 ] characters

Check-out date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. The overall duration of a stay cannot be longer than 30 days. You should not include time in this string.

nationality
required
string (Nationality) = 2 characters

Case-insensitive ISO 3166-1 alpha-2 code of nationality of guests/origin-country/source-market. e.g. ES, UA, CN, NL

best_price_only
boolean <date> (OnlyBestPrice)
Default: true

If true, will only return the lowest prices of each hotel. Default value is true. Please note that setting this to false will increase search time.

required
Array of objects (Room) [ 1 .. 6 ] items

Array of rooms with the number of adults and the age of children.

codes
required
Array of integers <int32> (CityCode) [ 1 .. 5 ] items [ items <int32 > ]

Array of city-codes. Can be a maximum of 5 different city codes. Note that overall count of viable hotels cannot be over 10,000

Responses

Request samples

Content type
application/json
Example
{
  • "check_in": "2022-07-08",
  • "check_out": "2022-07-10",
  • "nationality": "NL",
  • "codes": [
    ],
  • "rooms": [
    ]
}

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Near a GeoLocation

Search available hotels that are close to a latitude,logitude.

Request Body schema: application/json

Details of search

check_in
required
string <date> (CheckIn) [ 8 .. 10 ] characters

Check-in date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. Must be within today and up to a year from now. You should not include time in this string.

check_out
required
string <date> (CheckOut) [ 8 .. 10 ] characters

Check-out date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. The overall duration of a stay cannot be longer than 30 days. You should not include time in this string.

nationality
required
string (Nationality) = 2 characters

Case-insensitive ISO 3166-1 alpha-2 code of nationality of guests/origin-country/source-market. e.g. ES, UA, CN, NL

best_price_only
boolean <date> (OnlyBestPrice)
Default: true

If true, will only return the lowest prices of each hotel. Default value is true. Please note that setting this to false will increase search time.

required
Array of objects (Room) [ 1 .. 6 ] items

Array of rooms with the number of adults and the age of children.

required
object (geolocation)

Representing a geological location

required
object (Radius)

Maximum Distance from the geolocation

Responses

Request samples

Content type
application/json
{
  • "check_in": "2022-07-08",
  • "check_out": "2022-07-10",
  • "nationality": "NL",
  • "location": {
    },
  • "radius": {
    },
  • "rooms": [
    ]
}

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Inside a GeoBox

Search available hotels that are confined inside a geological box.

Request Body schema: application/json

Details of search

check_in
required
string <date> (CheckIn) [ 8 .. 10 ] characters

Check-in date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. Must be within today and up to a year from now. You should not include time in this string.

check_out
required
string <date> (CheckOut) [ 8 .. 10 ] characters

Check-out date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. The overall duration of a stay cannot be longer than 30 days. You should not include time in this string.

nationality
required
string (Nationality) = 2 characters

Case-insensitive ISO 3166-1 alpha-2 code of nationality of guests/origin-country/source-market. e.g. ES, UA, CN, NL

best_price_only
boolean <date> (OnlyBestPrice)
Default: true

If true, will only return the lowest prices of each hotel. Default value is true. Please note that setting this to false will increase search time.

required
Array of objects (Room) [ 1 .. 6 ] items

Array of rooms with the number of adults and the age of children.

required
object (TopLeftLocation)

Representing a geological location

required
object (BottomRightLocation)

Representing a geological location

Responses

Request samples

Content type
application/json
{
  • "check_in": "2022-07-08",
  • "check_out": "2022-07-10",
  • "nationality": "NL",
  • "top_left": {
    },
  • "bottom_right": {
    },
  • "rooms": [
    ]
}

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Based On Hotel

Search available hotels using a given list of hotel codes.

Request Body schema: application/json

Details of search

check_in
required
string <date> (CheckIn) [ 8 .. 10 ] characters

Check-in date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. Must be within today and up to a year from now. You should not include time in this string.

check_out
required
string <date> (CheckOut) [ 8 .. 10 ] characters

Check-out date of guests. Gregorian date in Y-mm-dd format such as: 2022-01-22. The overall duration of a stay cannot be longer than 30 days. You should not include time in this string.

nationality
required
string (Nationality) = 2 characters

Case-insensitive ISO 3166-1 alpha-2 code of nationality of guests/origin-country/source-market. e.g. ES, UA, CN, NL

best_price_only
boolean <date> (OnlyBestPrice)
Default: true

If true, will only return the lowest prices of each hotel. Default value is true. Please note that setting this to false will increase search time.

required
Array of objects (Room) [ 1 .. 6 ] items

Array of rooms with the number of adults and the age of children.

codes
required
Array of integers <int32> (HotelCode) [ 1 .. 2000 ] items [ items <int32 > ]

Array of hotel-codes. Can contain up to a maximum of 2000 hotel codes.

Responses

Request samples

Content type
application/json
Example
{
  • "check_in": "2022-07-08",
  • "check_out": "2022-07-10",
  • "nationality": "NL",
  • "codes": [
    ],
  • "rooms": [
    ]
}

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Pre-Book

Mandatory operations before reservation.

Get-Policies

This operation is required and must be called before booking an option. Prices before calling this end-point are subject to change. Make sure you handle the price changes after calling this end-point accordingly. Note that if an option becomes unavailable, it won't be included in the response; Handle this scenario accordingly.

Request Body schema: application/json
option_id
required
Array of strings (OptionIDs) [ 1 .. 10 ] items

Array of one or more option_ids received in /search

Responses

Request samples

Content type
application/json
{
  • "option_id": [
    ]
}

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Book

Reservation operations

Book

This is the final booking operation. You must check the resulting status and act accordingly.

  • confirmed: Your reservation has been confirmed on our system. No further action is necessary.
  • pending: Status of this reservation will change to either confirmed or rejected soon. You must check the details of this reservation every 5 minutes to get the updated status.
  • rejected: Your reservation has been rejected. Your credit is refunded, and you may try reserving another room, or another hotel.

Maximum response time of this action is 120 seconds.

Request Body schema: application/json
option_id
required
string = 24 characters

Unique option ID we've provided you with earlier. This will wrap all your selected rooms together.

pay_later
required
boolean

If your account has the permission, you may send this as true for options with active free_cancellation. Please note that you may get an error if you try to reserve an option without active free-cancellation, or if your account does not have the permission to book and pay later.

client_reference
string [ 2 .. 64 ] characters

Your internal reference for the booking.

required
Array of objects (Occupancy) [ 1 .. 6 ] items

Array of rooms along with their occupants(guests)

Responses

Request samples

Content type
application/json
{
  • "option_id": "62b35a4b3a9bee3ac1371025",
  • "pay_later": true,
  • "client_reference": "YourInternalRef",
  • "occupancies": [
    ]
}

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Booking List

Get the list of all your previous reservations

query Parameters
filter[id]
string
Example: filter[id]=H43454345

Return only one reservation(if available) with this specific booking id. Note that if necessary, you may also use GET /book/{id}.

filter[client_reference][like]
string
Example: filter[client_reference][like]=32432343

Search only for reservations that contain this string in their client reference (with partial matching)

filter[date][gte]
string
Example: filter[date][gte]=2022-05-01

Search only for reservations that are done on, or after this date

filter[date][lte]
string
Example: filter[date][lte]=2022-05-01

Search only for reservations that are done on, or before this date

filter[status]
string
Example: filter[status]=confirmed

Search only for reservations that have this status

page
number >= 1
Example: page=1

Page number, starting from 1.

perPage
number [ 1 .. 20 ]
Example: perPage=10

How many reservations should be returned in one page. Default=20

Responses

Response samples

Content type
application/json
{
  • "_meta": {
    },
  • "items": [
    ]
}

Pay for Booking

Pay for an unpaid booking and finalize it. This operation is used for reservations that are done with payment = false. Note that payment can only be false for reservations that do have a free-cancellation active at the time of booking.

path Parameters
booking_id
required
string

Responses

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Booking Details

Get the details of a reservation

path Parameters
booking_id
required
string

Responses

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Cancel a Booking

Request the cancellation of a booking(paid or unpaid). Note that only confirmed reservations that still have an unreached check-in date can be canceled. The refund amount(if any) will be according to the cancellation policies received in /get-policies before booking.

Maximum response time of cancellation is 120 seconds.

path Parameters
booking_id
required
string

Responses

Response samples

Content type
application/json
{
  • "ok": true,
  • "results": {
    }
}

Static Content

Static Content API is designed to offer detailed information about all the hotels available in our Booking API. The API provides various CSV files that allow you to access the hotels' details, as well as a range of features such as cities, hotel images, hotel descriptions, hotel facilities, and hotel issues. The purpose of this API is to offer comprehensive information about the hotels and their attributes.

Please be aware that the static content you receive in the TEST environment is intended only for testing purposes. Once you have got live credentials, it is necessary to retrieve the static content again.