How to get a session key from a Skyscanner API Submit request - Ruby

In my application, I want to get pricing information for the direct price of a flight. I used the SkyScanner API for this . I read the documentation before the resulting data I need to create a pricing service session. Which can be generated by the post api and then it provides SessionKey

with these SessionKey

and apiKey

, I can recover the data. So how can I get the Sessionkey as I figured it should be provided by the API server.

Here's my attempt:

require 'json'
require 'net/http'
require 'uri'

  post_params = { 
    :apiKey => "[API_KEY]",
    :country => "GB",
    :currency => "GBP",
    :locale => "en-GB",
    :adults =>1,
    :children => 0,
    :infants => 0,
    :originplace => '11235',
    :destinationplace => '13554',
    :outbounddate => '2015-05-19',
    :inbounddate => '2015-05-26',
    :locationschema => 'Default',
    :cabinclass => 'Economy',
    :groupPricing => true

sessionkey_request = Net::HTTP.post_form(URI.parse(''), post_params )
get_data= "[API_KEY]"
puts sessionkey_request.inspect
temp = Net::HTTP.get_response(URI.parse(get_data)).body
# puts temp


In the console I get

<Net::HTTPCreated 201 Created readbody=true> # sessionkey_request.inspect


Don't get a SessionKey in response without it I can't get data. Please guide me where I am wrong. I am grateful for the solution.

For more details and real-time results Check API demo

Note. I have a check gem 'skyscanner' but that doesn't provide any method for Live Price. It provides methods to view the cache.


source to share

1 answer

According to the document:

Successful response contains no content. The URL of the survey booking details are specified in the Location header of the response

try this:



I tested it on my system and it returns me:


The last part is yours sessionKey

, which you can use to query GET

. If you only want the last part (sessionKey), you can get it:

 > url = ""
 > url.split('/').last
 => "8e28260becd3441ca4e865396e224e7d_ecilpojl_EC71481935CEBB7EAF661BC24940D01D" 




All Articles