OpenBooking
Search…
Getting started
Getting started with our JavaScript SDK to build your own User Interface
Add the following script to your site:
1
var ob = new OBManager('https://api.openbooking.ch', '<insert token here>');
2
var query = {
3
"types": ["apartment"],
4
"language" : "de",
5
"currency" : "CHF",
6
//"checkin" : "",
7
//"checkout" : "",
8
//"rooms" : [
9
// { "adults": 2, "children": 0, "childrens_age": [] }
10
//]
11
};
12
var options = {
13
tracktag: "test"
14
, pageSize: 15
15
}
16
17
var items = ob.getItems(query, options)
Copied!
Get items returns a Items-Instance, this instance allows you to easily get successive pages by calling nextPage on it. You can call reset this way the next call to nextPage will return the first page again.
1
items.nextPage().then(function(page) {
2
console.log(page);
3
}).catch(function(err) {
4
console.log(err);
5
});
Copied!
You can also get a specific page directly based on its (zero based) index.
1
items.page(5).then(function(page) {
2
console.log(page);
3
}).catch(function(err) {
4
console.log(err);
5
});
Copied!
This also sets the internal state to page 5, this means that the next call to nextPage will return page 6.
If you call nextPage multiple times or use page with an index you will eventually reach the last page. The last page may have less elements then the specified pageSize. Requesting a page past the last page will return an empty array.
1
[{
2
city: "Sureggio (Lugano)",
3
city_normalized: "Sureggio (Lugano)",
4
externals: [],
5
features: [],
6
hookData: {
7
"classification": {
8
"statusCode":408,
9
"executed":"2016-10-14T10:11:54.434Z"
10
},
11
"resort": {
12
"statusCode":200,
13
"data":{
14
"resortKey":2632,
15
"regionId":"012"
16
}
17
,"executed":"2016-10-14T10:11:49.480Z"
18
}
19
},
20
id: "577d16f1074db10b006968d7",
21
images: [{
22
"season":"",
23
"url":"http://www.reka.ch/FewoImageList/sureggio_asb_01_.JPG-940x622-79330.jpg"
24
},{
25
"season":"",
26
"url":"http://www.reka.ch/FewoImageList/sureggio_feriensiedlung_asb_06_.jpg-940x622-79330.jpg"
27
},{
28
"season":"",
29
"url":"http://www.reka.ch/FewoImageList/sureggio_feriensiedlung_aan_01_.jpg-940x622-79330.jpg"
30
},{
31
"season":"",
32
"url":"http://www.reka.ch/FewoImageList/sureggio_aso_01_.jpg-940x622-79330.jpg"
33
},{
34
"season":"",
35
"url":"http://www.reka.ch/FewoImageList/sureggio_feriensiedlung_aso_22_.jpg-940x622-79330.jpg"
36
},{
37
"season":"",
38
"url":"http://www.reka.ch/FewoImageList/sureggio_feriensiedlung_aso_600_.JPG-940x622-79330.jpg"
39
},{
40
"season":"summer",
41
"url":"http://www.reka.ch/FewoImageList/sureggio_feriensiedlung_aso_05_.jpg-940x622-79330.jpg"
42
},{
43
"season":"winter",
44
"url":"http://www.reka.ch/FewoImageList/sureggio_feriensiedlung_aso_01_.tif-940x622-79330.jpg"
45
}],
46
imagesServices: [],
47
name: {"de":"Feriensiedlung Sureggio, Sureggio "},
48
name_add: {"de":"Typ K, 3-Zi.-Wohnung/5 Pers., 55m², Parterre"},
49
position: {"lat":46.0535013359,"lng":8.9730388081},
50
provider_name: "reka",
51
quality: "3",
52
ranks: [],
53
superior: false,
54
type: "apartment",
55
visible: true
56
},
57
{
58
city: "Moléson (ob Greyerz)",
59
city_normalized: "Moléson (ob Greyerz)",
60
externals: [],
61
features: [],
62
hookData: {
63
"classification": {
64
"statusCode":408,
65
"executed":"2016-10-14T10:11:54.756Z"
66
},
67
"resort": {
68
"statusCode":200,
69
"data": {
70
"resortKey":795,
71
"regionId":"013"
72
},
73
"executed":"2016-10-14T10:11:49.802Z"
74
}
75
},
76
id: "577d16f1a20ea20c009fbbd3",
77
images: [{
78
"season":"",
79
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_awi_200_.jpg-940x622-101335.jpg"
80
},{
81
"season":"",
82
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_iwz_01_.jpg-940x622-101335.jpg"
83
},{
84
"season":"",
85
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_iwz_02_.jpg-940x622-101335.jpg"
86
},{
87
"season":"",
88
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_iku_02_.jpg-940x622-101335.jpg"
89
},{
90
"season":"",
91
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_ibd_03_.jpg-940x622-101335.jpg"
92
},{
93
"season":"",
94
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_ibd_04_.jpg-940x622-101335.jpg"
95
},{
96
"season":"summer",
97
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_aso_03_.jpg-940x622-101335.jpg"
98
},{
99
"season":"winter",
100
"url":"http://www.reka.ch/FewoImageList/moleson_andromede_awi_01_.tif-940x622-101335.jpg"
101
}],
102
imagesServices: [],
103
name: {"de":"Andromède"},
104
name_add: {"de":"Typ B, 2-Zi.-Wohnung/4 Pers., 53m², 1. Stock"},
105
position: {"lat":46.5627267438,"lng":7.0354476192},
106
provider_name: "reka",
107
quality: "3",
108
ranks: [],
109
superior: false,
110
type: "apartment",
111
visible: true
112
}, ...]
Copied!
pageCount returns the number of pages. This is useful if you want to show a pager below your results.
1
items.pageCount().then(function(count) {
2
console.log(count);
3
}).catch(function(err) {
4
console.log(err);
5
});
Copied!
Last modified 1yr ago
Copy link