3

Getting Hotel Listing Using SkyScanner API

scyscanner hotel api php
If one needs to build a travel product for his own, then SkyScanner is the cheapest, and probably the most efficient option to rely upon. SkyScanner with its powerful API and tools fetches the user with all the information needed for a travel website or app, that including flight searching, flights price comparisons, searching of hotels and cars, listing of hotels from all over the world, car hiring etc. and most importantly, this all at free.

In this tutorial, we will learn to use the SkyScanner API for retrieving the hotels information.

The very first thing to use SkyScanner API is to obtain an API key, which you can easily get after creating an account with SkyScanner.

PHP Code to Get Hotel Information from SkyScanner

SkyScanner first creates a session for any API operation made by the user as the first phase, and then in the next phase allows users to get the information about any of its resources within that session by passing the unique session ID inside the api calling URL, this phase is called Polling of session.

Hotel Details Information:

First you need to get an individual ID for the location, where you need to search the hotels. For this you will have to use Skyscanner Hotels Autosuggest Service API.

Here is the sample code:

Note: pari is the keyword for the place , you can use yours like delhi, mascow etc.

I have used UK (market), en_GB (locale) and EUR (currency) in my code, you can replace these with your choice.

Now in the output -> results, select individual_id for the value of your choice and pass it to the next step.

This will output the hotels with very limited information. But you can use the hotel Id to get the detailed information for that hotel.

You May Also Like:

Instagram API Integration Into Website
How to Install Magento Security Patch via Putty
Code to Use Paypal Payment Gateway on Website
How to Authenticate with D&B Direct API Web Service
How to Add New Product in Bigcommerce via API V2
How to Connect With Cloudshare Rest API

Here is the Code:

Please notice that $url_detail is the utmost required session URL to poll the session for getting hotel details.
Like this :

Here is the Complete Code:

You are advised to follow the SkyScanner API documentation for using other features of Skyscanner. Using this api service you can get Flight and Cars booking data.

Manish Kumar

3 Comments

  1. Hi,

    thank you for example.
    I would like to know where does this code goes if website is devoloped in wordpress.
    Is it needed to build a plugin or just some .php fiile?
    I would like to know because I would try to build a flight, hotel, car search website with skyscanner api.
    Thank you in advance!

    Regards!
    Marko

    • Hi Marko,

      In wordpress you can create a .php template file under active theme folder. Place skyscanner code in that file.

      Than create a new page and use that created template to publish it. You get data on that page.

      Thanks

  2. Thank you for the reply.
    I’ve have don everything you wrote but there is some error in the template. How the template header should look like?
    Regards,
    Marko

Leave a Reply

Your email address will not be published. Required fields are marked *