-
Notifications
You must be signed in to change notification settings - Fork 5
Request a property
Each resource contained within the API is identified by a [URI](Uniform resource identifier). To get the details of a resource, you simply send a GET HTTP request to the URI of that resource. This can be done simply by opening up the URI in your web-browser of choice:- http://carltonsoftware.apiary.io/property/mousecott_SS. The response is encoded in JSON format, and can be converted into a native PHP object/array using the json_decode function (other languages should have their own functions to decode JSON).
Whilst this is nice and simple, it isn't much use to an application. Below are a couple of examples of how to perform a simple HTTP GET request using some common tools. You can also find some more examples, including how to send POST's, PUT's and DELETE's in the examples folder.
Request (using the curl command line tool)
$ curl http://carltonsoftware.apiary.io/property/mousecott_SS
Request (using the PHP curl plugin)
<?php
//The URI to request
$uri = 'http://carltonsoftware.apiary.io/property/mousecott_SS';
//Create a new curl connection
$ch = curl_init();
// Set the URI that we want to request
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
//Perform the request, and assign the response to $response
$response = curl_exec($ch);
//Print out the response
print $response;
Response
{
"id": "mousecott_SS",
"propertyRef": "mousecott",
"brandCode": "SS",
"url": "http://carltonsoftware.apiary.io/property/mousecott_SS",
"accountingBrand": "SS",
"slug": "mouse-cottage-southwold",
"name": "Mouse Cottage",
"address": {
"addr1": "The Street",
"addr2": "",
"town": "Southwold",
"county": "Suffolk",
"postcode": "IP1 2AB",
"country": "GB"
},
"coordinates": {
"latitude": 52.2345,
"longitude": 1.2345
},
"area": {
"code": "COAST",
"name": "Suffolk Coast"
},
"location": {
"code": "SOUTH",
"name": "Southwold"
},
"brands": {
"SS": {
"teaser": "Lorem (availability field)",
"short": "Lorem",
"description": "Lorem",
"pricing": {
"bookingBrand": "SS",
"ranges": {
"2012": {
"high": 998,
"low": 325
},
"2013": {
"high": 1024,
"low": 275
}
}
}
}
},
"accommodates": 10,
"bedrooms": 4,
"changeOverDay": "saturday",
"shortBreak": true,
"rating": 0,
"pets": true,
"promote": true,
"attributes": {
"washingMachine": true,
"broadband": true,
"distanceFromPub": 2
},
"images": [
{
"filename": "filename1.png",
"url": "http://carltonsoftware.apiary.io/image/original/1x1/filename1.png",
"alt": "Mouse Cottage - blue front door",
"title": "Mouse Cottage",
"width": "640",
"height": "480"
},
{
"filename": "filename2.png",
"url": "http://carltonsoftware.apiary.io/image/original/1x1/filename2.png",
"alt": "Mouse Cottage - courtyard garden",
"title": "Mouse Cottage garden",
"width": "480",
"height": "640"
}
],
"specialOffers": [
{
"fromDate": "2012-06-09",
"toDate": "2012-07-14",
"description": "10% discount for full week stays between 9 June and 14 July 2012",
"type": "%",
"amount": 10
},
{
"fromDate": "2012-07-14",
"toDate": "2012-07-21",
"description": "£50 discount for full week stays between 14 July 2012 and 21 July 2012",
"type": "£",
"amount": 50
},
{
"fromDate": "2012-11-01",
"toDate": "2012-11-30",
"description": "10% discount for full week stays between 1 Nov and 30 Nov 2012",
"type": "%",
"amount": 10
}
],
"calendar": "http://carltonsoftware.apiary.io/property/mousecott_SS/calendar",
"booking": "http://carltonsoftware.apiary.io/booking"
}