Skyscanner has currently three Skytools APIs you can use in your web pages with no server side code: Maps API, WhoFlies API and FlightSearch API. To use any or all of these in your web pages, you only need to include a single <script> tag at the top of your web page with your Skytools API key:
<script type="text/javascript" src="http://api.skyscanner.net/api/ajax/loader.js?key=ABCDEFGH"></script>
If you don't yet have a Skyscanner API key, you can sign up for an API key for free.
Once the Skyscanner Skytools APIs script is loaded, you specify the modules you want to use on your page with skyscanner.load:
skyscanner.load('maps', '1'); // loads Skyscanner Maps API
The example above loads version 1 of the Maps API. After you call skyscanner.load, you can use all of the loaded modules in your web page. In addition, use skyscanner.setOnLoadCallback to register the specified handler function to be called once the document loads. Here is an example that puts it all together:
<html>
<head>
<script type="text/javascript" src="http://api.skyscanner.net/api/ajax/loader.js?key=ABCDEFGH"></script>
<script type="text/javascript">
skyscanner.load('maps', '1'); // loads Skyscanner Maps API
function main(){
// create map
var map = new skyscanner.maps.Map();
// configure map
map.setRoute('LOND',''); // marks London in UK as departure place
// display map
map.draw(document.getElementById('map'));
};
skyscanner.setOnLoadCallback(main);
</script>
</head>
<body>
<div id="map">
<a href="http://www.skyscanner.net/en/flights-from/lond/cheap-flights-from-london.html" target="_blank">Cheap Flights from London</a>
</div>
</body>
</html>
The Skyscanner Skytools APIs <script> tag loads a single method (skyscanner.load) which loads individual Skytools APIs. It has the following prototype:
skyscanner.load(moduleName, moduleVersion, optionalSettings)
moduleName is the name of the API (e.g. 'maps' or 'snippets'). The module name also serves as the namespace of the API once it is loaded.
moduleVersion specifies the version of the API module, as described below. It is a required argument; which means you must always specify the version of the API you are using. If you are unsure of which version you want to use, you should employ the version used in the documentation and examples for the API you are using.
optionalSettings specifies all optional configuration options for the API you are loading as a JavaScript object literal. Refer to API documentation for finding out about these settings.
nocss default false. When true then default CSS file is not loaded
skyscanner.load('snippets', '1', {'nocss' : true}); // default CSS file is not loaded
overridecss specifies URL to CSS file which is loaded during the load of snippet content. It can be used to override default CSS styles
The module name of an API is also its namespace. So symbols from the "maps" module are available under the namespace skyscanner.maps when the module loads.
The second parameter of skyscanner.load is the version of the API. Every Skytools API has a major version and a revision number, of the form VERSION.REVISION. Every time an Skytools API introduces new code, the revision number is incremented. Thus if the WhoFlies API is on version 2.3, and the Skyscanner team does an update, the new code would be version 2.4
Whenever there is a major version upgrade we will send email information about it and the previous version will be available for a few more months.
Our Skytools APIs are updated from time to time, so to ensure stability, all of our Skytools APIs have an active stable version and a test version. Every time Skyscanner introduces a new API revision, e.g. 2.4, the previous revision, 2.3, would become the stable version of the API with version 2.4 being the test version. If you requested version 2 of the API without a revision specified, you would automatically get the stable revision of the API, 2.3. To get the test version of the API, you could request version 2.4 explicitly, or you could use the special wildcard 2.x, which would always refer to the test version of the API. In this example, version 2.4 would remain the test version until the next revision was pushed.
We would encourage you to use the stable version of each API (e.g. 2) in production HTML and test version of each API (e.g. 2.x) on your development machines, and report to us any issues you find for that API. If many users encounter serious issues with a particular API revision, Skyscanner will revert or hold back the revision.
Whilst technically you can request any older version of an API any time, old versions of APIs are not officially supported and in many cases, server-side changes will require that you stop using old versions of the API. However, we will try to keep old versions of each API on our servers for long periods of time so that developers who depend on legacy versions of APIs have as much time to upgrade as possible.The following Skyscanner Skytools APIs are available: