Welcome to Skyscanner Python SDK’s documentation!¶
Contents:
Skyscanner Python SDK¶
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
Features¶
- Tested on Python 2.6, 2.7, 3.3, 3.4
- Supports Flights, Hotels, and Carhire
Installation¶
At the command line:
$ easy_install skyscanner
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv skyscanner
$ pip install skyscanner
Quick start¶
Request for an API Key from Skyscanner for Business Contact Page.
Set your API Key:
from skyscanner.skyscanner import Flights flights_service = Flights('<Your API Key>')
Get the flights live pricing result by writing a few lines of code:
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='2016-07-28', inbounddate='2016-07-31', adults=1).parsed print(result)
Note that both the inbounddate
and outbounddate
might need to be updated.
More examples¶
For more example usage, refer to our documentation.
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.
Installation¶
At the command line:
$ easy_install skyscanner
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv skyscanner
$ pip install skyscanner
Usage¶
To use Skyscanner Python SDK in a project, make sure that you set your API Key. For example:
from skyscanner.skyscanner import Flights
flights_service = Flights('<Your API Key>')
Flights: Live Pricing¶
http://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',
adults=1).parsed
Flights: Browse Cache¶
http://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheOverview
Cheapest quotes:
from skyscanner.skyscanner import FlightsCache
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
Cheapest price by route:
from skyscanner.skyscanner import FlightsCache
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
Cheapest price by date:
from skyscanner.skyscanner import FlightsCache
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
Grid of prices by date:
from skyscanner.skyscanner import FlightsCache
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
Car Hire¶
http://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',
driverage='30',
userip='175.156.244.174').parsed
Car hire autosuggest:
from skyscanner.skyscanner import CarHire
carhire_service = CarHire('<Your API Key>')
result = carhire_service.location_autosuggest(
market='UK',
currency='GBP',
locale='en-GB',
query='Kuala').parsed
Hotels¶
http://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',
query='Kuala').parsed
Hotels prices and details:
from skyscanner.skyscanner import Hotels
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
Contributing to Skyscanner’s Python SDK¶
We’re glad you want to make a contribution!
Fork this repository and send in a pull request when you’re finished with your changes. Link any relevant issues in too.
Take note of the build status of your pull request, only builds that pass will be accepted. Please also keep to our conventions and style so we can keep this repository as clean as possible.
License¶
By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/Skyscanner/skyscanner-python-sdk/blob/master/LICENSE.md
All files are released with the Apache 2.0 license.
If you are adding a new file it should have a header like this:
/**
- Copyright 2015 Skyscanner Limited.
- Licensed under the Apache License, Version 2.0 (the “License”);
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an “AS IS” BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and * limitations under the License.
*/
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/Skyscanner/skyscanner-python-sdk/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
Skyscanner Python SDK could always use more documentation, whether as part of the official Skyscanner Python SDK docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/Skyscanner/skyscanner-python-sdk/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up skyscanner for local development.
Fork the skyscanner repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/skyscanner-python-sdk.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv skyscanner $ cd skyscanner/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 skyscanner tests $ python setup.py test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check https://travis-ci.org/Skyscanner/skyscanner-python-sdk/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Ardy Dedase <ardy.dedase@skyscanner.net>
Contributors¶
- Denis Dudnik <deniska.dudnik@gmail.com>
- Kelvin Tay <kelvintaywl@gmail.com>
History¶
1.0.0 (2015-03-24)¶
- First release on PyPI.
1.1.0 (2015-07-18)¶
- Stable release on PyPI.
1.1.1 (2015-08-01)¶
- Fixes for Python 2.6, 3.3, and 3.4.
1.1.2 (2015-08-01)¶
- Support additional params for Flights Pricing Service. Fix for issue #15.
1.1.3 (2015-08-01)¶
- Set default error handling to graceful. Fix for issue #19.