Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ language: python

python:
- "3.4"
- "3.3"
- "2.7"
- "pypy"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
Expand All @@ -15,5 +14,5 @@ install:
script:
- flake8
- python runtests.py
- coverage run --source skyscanner setup.py test
after_success: coveralls
- coverage run --source skyscanner setup.py test
after_success: coveralls
42 changes: 31 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Skyscanner Python SDK
===============================

Important
=========
As of May 1st, 2020, the project is deprecated and no longer maintained.
The latest update in v1.1.5 includes changing the library to use a secure connection when calling Skyscanner's APIs as this is required for all users and http is no longer supported. The development of this SDK from that point on is fully abandoned.

As we cannot guarantee for how long it will continue working, you should not to use the SDK when starting new projects. If it is already in use in your projects, please upgrade to its latest version and keep in mind that due to planned changes in our Skyscanner APIs it may not work as expected after July 2020.


You will need to contact us to request an API key to use our APIs via the following form: https://partners.skyscanner.net/contact.

We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful.

.. image:: https://api.travis-ci.org/Skyscanner/skyscanner-python-sdk.svg
:target: https://travis-ci.org/Skyscanner/skyscanner-python-sdk

Expand All @@ -20,7 +32,7 @@ Skyscanner Python SDK for Skyscanner's API

* Free software: Apache license
* SDK Documentation: https://skyscanner.readthedocs.org.
* API Documentation: http://business.skyscanner.net/portal/en-GB/Documentation/ApiOverview
* API Documentation: https://business.skyscanner.net/portal/en-GB/Documentation/ApiOverview


Features
Expand All @@ -46,13 +58,15 @@ Or, if you have virtualenvwrapper installed::
Quick start
-----------

1. Request for an API Key from `Skyscanner for Business Contact Page`_.
2. Set your API Key::
1. Contact us to request an API key: https://partners.skyscanner.net/contact
2. If you don't already have one, create a `Skyscanner account`_.
3. Sign into your account and click 'Import Existing App' and use your API key to create an App
4. Set your API Key in your code::

from skyscanner.skyscanner import Flights
flights_service = Flights('<Your API Key>')

3. Get the flights live pricing result by writing a few lines of code::
5. Get the flights live pricing result by writing a few lines of code::

from skyscanner.skyscanner import Flights

Expand All @@ -63,29 +77,35 @@ Quick start
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2016-07-28',
inbounddate='2016-07-31',
outbounddate='2017-05-28',
inbounddate='2017-05-31',
adults=1).parsed

print(result)

Note that both the ``inbounddate`` and ``outbounddate`` might need to be updated.

.. _Skyscanner for Business Contact Page: http://en.business.skyscanner.net/en-gb/contact/
.. _Skyscanner account: https://partners.skyscanner.net/log-in/


More examples
-------------

For more example usage, `refer to our documentation`_.
For more example usage, refer to the `SDK documentation`_ or the `API documentation`_.

.. _SDK documentation: https://skyscanner.readthedocs.org/en/latest/usage.html
.. _API documentation: https://skyscanner.github.io/slate/

.. _refer to our documentation: https://skyscanner.readthedocs.org/en/latest/usage.html


Known Issues
------------

* Tests might appear to be broken sometimes, this is due to the throttling in the API. In such cases, you will see the following error in the build log::

requests.exceptions.HTTPError: 429 Client Error: Too many requests in the last minute.


* Please allow up to 15 minutes for your API key to be activated. Until it is activated you will get a 403 exception::

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://partners.api.skyscanner.net/apiservices/pricing/v1.0?apiKey=<Your API key>


126 changes: 64 additions & 62 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,39 @@
Usage
========

To use Skyscanner Python SDK in a project, make sure that you set your API Key. For example::
To use Skyscanner Python SDK in a project, you will need to request an API key. Please use the following form: https://partners.skyscanner.net/contact/

Once you have an API key you can set it as follows:

from skyscanner.skyscanner import Flights
flights_service = Flights('<Your API Key>')

flights_service = Flights('<Your API Key>')


Flights: Live Pricing
~~~~~~~~~~~~~~~~~~~~~

http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList
https://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList

Get live prices::

from skyscanner.skyscanner import Flights

flights_service = Flights('<Your API Key>')
result = flights_service.get_result(
country='UK',
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2015-05-28',
inbounddate='2015-05-31',
country='UK',
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2017-05-28',
inbounddate='2017-05-31',
adults=1).parsed

Flights: Browse Cache
~~~~~~~~~~~~~~~~~~~~~

http://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheOverview
https://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheOverview

Cheapest quotes::

Expand All @@ -41,12 +43,12 @@ Cheapest quotes::
flights_cache_service = FlightsCache('<Your API Key>')
result = flights_cache_service.get_cheapest_quotes(
market='UK',
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2015-05',
inbounddate='2015-06').parsed
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2017-05',
inbounddate='2017-06').parsed

Cheapest price by route::

Expand All @@ -55,12 +57,12 @@ Cheapest price by route::
flights_cache_service = FlightsCache('<Your API Key>')
result = flights_cache_service.get_cheapest_price_by_route(
market='UK',
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2015-05',
inbounddate='2015-06').parsed
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2017-05',
inbounddate='2017-06').parsed

Cheapest price by date::

Expand All @@ -69,12 +71,12 @@ Cheapest price by date::
flights_cache_service = FlightsCache('<Your API Key>')
result = flights_cache_service.get_cheapest_price_by_date(
market='UK',
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2015-05',
inbounddate='2015-06').parsed
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2017-05',
inbounddate='2017-06').parsed

Grid of prices by date::

Expand All @@ -83,31 +85,31 @@ Grid of prices by date::
flights_cache_service = FlightsCache('<Your API Key>')
result = flights_cache_service.get_grid_prices_by_date(
market='UK',
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2015-05',
inbounddate='2015-06').parsed
currency='GBP',
locale='en-GB',
originplace='SIN-sky',
destinationplace='KUL-sky',
outbounddate='2017-05',
inbounddate='2017-06').parsed

Car Hire
~~~~~~~~

http://business.skyscanner.net/portal/en-GB/Documentation/CarHireLivePricing
https://business.skyscanner.net/portal/en-GB/Documentation/CarHireLivePricing

Get live prices::

from skyscanner.skyscanner import CarHire

carhire_service = CarHire('<Your API Key>')
result = carhire_service.get_result(
market='UK',
currency='GBP',
locale='en-GB',
pickupplace='LHR-sky',
dropoffplace='LHR-sky',
pickupdatetime='2015-05-29T12:00',
dropoffdatetime='2015-05-29T18:00',
market='UK',
currency='GBP',
locale='en-GB',
pickupplace='LHR-sky',
dropoffplace='LHR-sky',
pickupdatetime='2017-05-29T12:00',
dropoffdatetime='2017-05-29T18:00',
driverage='30',
userip='175.156.244.174').parsed

Expand All @@ -117,25 +119,25 @@ Car hire autosuggest::

carhire_service = CarHire('<Your API Key>')
result = carhire_service.location_autosuggest(
market='UK',
currency='GBP',
locale='en-GB',
market='UK',
currency='GBP',
locale='en-GB',
query='Kuala').parsed

Hotels
~~~~~~

http://business.skyscanner.net/portal/en-GB/Documentation/HotelsOverview
https://business.skyscanner.net/portal/en-GB/Documentation/HotelsOverview

Hotels autosuggest::

from skyscanner.skyscanner import Hotels

hotels_service = Hotels('<Your API Key>')
result = hotels_service.location_autosuggest(
market='UK',
currency='GBP',
locale='en-GB',
market='UK',
currency='GBP',
locale='en-GB',
query='Kuala').parsed

Hotels prices and details::
Expand All @@ -144,11 +146,11 @@ Hotels prices and details::

hotels_service = Hotels(self.api_key)
result = hotels_service.get_result(
market='UK',
currency='GBP',
locale='en-GB',
entityid=27543923,
checkindate='2015-05-26',
checkoutdate='2015-05-30',
guests=1,
rooms=1).parsed
market='UK',
currency='GBP',
locale='en-GB',
entityid=27543923,
checkindate='2017-05-26',
checkoutdate='2017-05-30',
guests=1,
rooms=1).parsed
2 changes: 1 addition & 1 deletion skyscanner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
__author__ = 'Ardy Dedase'
__email__ = 'ardy.dedase@skyscanner.net'
__version__ = '1.1.3'
__version__ = '1.1.5'
__copyright__ = "Copyright (C) 2016 Skyscanner Ltd"
__license__ = """
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
17 changes: 9 additions & 8 deletions skyscanner/skyscanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def configure_logger(log_level=logging.WARN):
logger.addHandler(sa)
return logger


log = configure_logger()
STRICT, GRACEFUL, IGNORE = 'strict', 'graceful', 'ignore'

Expand Down Expand Up @@ -73,7 +74,7 @@ class Transport(object):
"""
Parent class for initialization
"""
API_HOST = 'http://partners.api.skyscanner.net'
API_HOST = 'https://partners.api.skyscanner.net'
MARKET_SERVICE_URL = '{api_host}/apiservices/reference/v1.0/countries'\
.format(api_host=API_HOST)
LOCATION_AUTOSUGGEST_URL = '{api_host}/apiservices/autosuggest/v1.0'\
Expand All @@ -92,7 +93,7 @@ def __init__(self, api_key, response_format='json'):
if response_format.lower() not in self._SUPPORTED_FORMATS:
raise ValueError(
'Unknown response format: {}'.format(response_format) +
', supported formats are '.format(
+ ', supported formats are '.format(
', '.join(self._SUPPORTED_FORMATS)
)
)
Expand Down Expand Up @@ -202,7 +203,7 @@ def make_request(self, service_url, method='get', headers=None, data=None,
def get_markets(self, market):
"""
Get the list of markets
http://business.skyscanner.net/portal/en-GB/Documentation/Markets
https://business.skyscanner.net/portal/en-GB/Documentation/Markets
"""
url = "{url}/{market}".format(url=self.MARKET_SERVICE_URL,
market=market)
Expand All @@ -213,13 +214,13 @@ def location_autosuggest(self, **params):
Location Autosuggest Services
Doc URLs:

http://business.skyscanner.net/portal/en-GB/
https://business.skyscanner.net/portal/en-GB/
Documentation/Autosuggest

http://business.skyscanner.net/portal/en-GB/
https://business.skyscanner.net/portal/en-GB/
Documentation/CarHireAutoSuggest

http://business.skyscanner.net/portal/en-GB/
https://business.skyscanner.net/portal/en-GB/
Documentation/HotelsAutoSuggest

Format:
Expand Down Expand Up @@ -424,7 +425,7 @@ class Flights(Transport):
Flights Live Pricing

Please see:
http://business.skyscanner.net/portal/en-GB/
https://business.skyscanner.net/portal/en-GB/
Documentation/FlightsLivePricingList
"""

Expand Down Expand Up @@ -465,7 +466,7 @@ class FlightsCache(Flights):
Flights Browse Cache

Please see:
http://business.skyscanner.net/portal/en-GB/
https://business.skyscanner.net/portal/en-GB/
Documentation/FlightsBrowseCacheOverview
"""

Expand Down
Loading
Loading