Skip to content

Instantly share code, notes, and snippets.

@soncojmk
Last active February 4, 2021 00:03
Show Gist options
  • Save soncojmk/c1b0333661176b3e79edef5f4768f92f to your computer and use it in GitHub Desktop.
Save soncojmk/c1b0333661176b3e79edef5f4768f92f to your computer and use it in GitHub Desktop.
Skyscanner point of sale hack to get the cheapest prices by changing the country of sale until the cheapest routes are determined instead of using a VPN. Sometimes saves up to $1,000
'''You first have to install the skyscanner python sdk by 'pip install skyscanner' '''
'''You also have to get an api key from skyscanner before using this'''
from skyscanner.skyscanner import FlightsCache
from urllib.request import urlopen
import json
''' Get the country codes'''
url = 'http://partners.api.skyscanner.net/apiservices/reference/v1.0/countries/en-US?apiKey={apikey}'
request = urlopen(url).read().decode('utf8')
obj = json.loads(request)
countries = obj['Countries']
markets = []
for i in countries:
markets.append(i['Code'])
'''Get the cached flights '''
flights_cache_service = FlightsCache('<api-key>')
result = {}
cheapest_countries = []
'''Go through every market and append the result to the results dictionary'''
for i in markets:
response = result.update(flights_cache_service.get_cheapest_quotes(market=i,currency='USD',locale='en-US', originplace='JFK-sky',destinationplace='CDG-sky',outbounddate='2017-04-18', inbounddate='2017-04-28').parsed)
if(response):
result.update(response)
sorted_list = sorted(result['Quotes'], key=lambda q: q['MinPrice'])
print(sorted_list[:10])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment