In my app I want to fetch Live Price by Flight Details for this I have used SkyScanner API. I have read the documentation before obtained data I have to create Live Pricing Service Session. Which can be created by post request to api and then it provide SessionKey
by using this SessionKey
and apiKey
I can retrived the data. So How can I get Sessionkey as I understood it must be provided by API Server.
Here is my try:
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('http://partners.api.skyscanner.net/apiservices/pricing/v1.0'), post_params )
get_data= "http://partners.api.skyscanner.net/apiservices/pricing/v1.0/?apiKey=[API_KEY]"
puts sessionkey_request.inspect
temp = Net::HTTP.get_response(URI.parse(get_data)).body
# puts temp
In console I get
<Net::HTTPCreated 201 Created readbody=true> # sessionkey_request.inspect
Not getting SessionKey in response without it I can not retrieved data. Please guide me where I do mistake. I appreciate for solution.
Fore more details and live result Check Demo by API
Note: I have check gem 'skyscanner ' but it doesn't provide any method for Live Price. It provide Browse Cache methods.