javascriptdocumentationskyscanner

SkyScanner JavaScript API


I'm using SkyScanner's flight search widget on my website. The JS code that they give you to embed in your website is:

<script src="http://api.skyscanner.net/api.ashx" type="text/javascript"></script>

<script type="text/javascript">
    skyscanner.load('snippets', '2');
    function main() {
        var snippet = new skyscanner.snippets.SearchPanelControl();
        snippet.setCurrency('EUR');
        snippet.setUrlParam('associateid', 'AFF_NTW_00014_00001');
        snippet.setUrlParam('pid', '6439791');
        snippet.setUrlParam('aid', '10644591');
        snippet.setClickUrl('http://www.jdoqocy.com/click-6439791-10644591?sid=&url=@@url@@');
        snippet.setShape('leaderboard');
        snippet.setDeparture('ie');
        snippet.draw(document.getElementById('snippet_searchpanel'));
    }
    skyscanner.setOnLoadCallback(main);
</script>

By inspecting the prototype of SearchPanelControl I discovered lots of other functions that could be useful e.g. for setting the initial flight dates. However, I can't find any documentation for this API that explains what parameters each function expects.

I tried looking for the definition of skyscanner.snippets.SearchPanelControl in the file http://api.skyscanner.net/api.ashx, but it doesn't seem to be there. Does anyone know where this is documented, or alternatively, where I can find the source code thereof?


Solution

  • The underlying JavaScript for all of the widgets has recently been re-written/updated, but interfaces are unchanged.

    The two modules that can be pulled in are snippets (for the Flight Search widget) and maps (for the Map widget). Each of these modules have their own configuration options. The easiest way to get a list of these and the their values is to view the output on the Create Your Widgets page (and click Update and generate code with a dummy key).

    Any options documented on the above page are supported. We periodically add new options as we implement new features on the widgets (We plan on adding some shortly, I'll drop a comment on here when we do).

    As you said, there are many more undocumented options in the underlying JavaScript file, you're more than welcome to use any/all of these but we can't guarantee their availability long term.

    This is a relatively new area for us, so let us know if you have any other feedback.

    Iain