The Javascript Data API allows basic access to the Outdooractive Data API. Simple Method calls perform requests to the Data API in the background asynchronously and callback methods receive the data of the responses.

Objects API

Use the objects API to load OOI data from server side. The objects API takes care of the complete data transfer including x-domain support and makes OOI data available on client side through an easy to use interface:

// load data of a single OOI
// Note: oax only (Desktop)
new oax.api.SingleOOI( id ).load(

    // callback function
    function ( ooi, point ) {

        // do something with the loaded ooi data
        alert( ooi.data.title );

    }

);

// load data of multiple OOIs at once
// Note: oax only (Desktop)
new oax.api.OOIs( 
    {
        // list of string ids
        idlist: ["123", "234"],
        // optional argument to load only basic information about each OOI
        lightweightApp: 'tour'
    }

).load( 

    // callback function
    function( status, oois ) {

        // do something with the loaded ooi data
        if (oois.length>0) {
            console.debug( oois[0].title );
        }

    }

);

Request Ids

The Search API, Filter API, Top Tipps API and NearBy API use all the same method:

// request object
var request = { search : "hotel" };

// keep a reference to the last request
// (e.g. if user interaction may lead to multiple requests)
var last_request = request;

// send the request...
oa.api.requestIds( request, callback );

// callback function with answer object
function callback( answer ) {

    // check if request was successfull
    if (answer.success) {

        // ignore response if another request was sent
        if (answer.request === last_request) {

            // grab ids from answer object
            var ids = answer.data.ids;

        }

    }
}

Search API

Full text search:

oa.api.requestIds( { search : "hotel" }, callback );

Filter API

Tour Filter:

oa.api.requestIds( { filter : { asc_s : 500 } }, callback );

Top Tipps API

All Top Tipps of a project:

oa.api.requestIds( "toptipps", callback );

Near By API

Request a list of tour ids inside a radius around a location:

// request object
var request = { 
    searchNearby : 
    { 
        // the search center
        location : {lat:47, lng:10},

        // the search radius (unit: meters)
        radius : 5000

        // the result list will be sorted by distance
        sortby: "distance"
    }
};

// send the nearby request
oa.api.requestIds( request, callback );