Marketing API Version

Hotel

Reading

A hotel object.

Examples

Graph API Explorer
GET /v2.10/{hotel-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{hotel-id}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
/* make the API call */
FB.api(
    "/{hotel-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{hotel-id}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{hotel-id}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
If you want to learn how to use the Graph API, read our Using Graph API guide.

Parameters

This endpoint doesn't have any parameters.

Fields

FieldDescription

id

numeric string

The unique ID of the hotel generated by Facebook

address

string

The address of the hotel

applinks

App links for native platforms, e.g. Android, IOS and Windows Phone

brand

string

Hotel Brand

description

string

Description of the hotel

guest_ratings

string

Guest ratings for this hotel

hotel_id

string

A unique identifier for this hotel provided by advertiser (i.e. from the hotel_id field in the feed)

images

list<string>

Links to hotel images. Please note that carousel format utilizes a square 1:1 aspect ratio images (recommended size - 600x600px) while single hotel ad uses 1.91:1 aspect ratio image(recommended size - 1200x630px). Please provide at least one image

lowest_base_price

string

The lowest base price for rooms in this hotel

loyalty_program

string

Catalog item text field: LoyaltyProgram

margin_level

unsigned int32

An indicator of the profitability of the hotel

name

string

Hotel name

phone

string

Hotel's phone number

star_rating

float

The star rating of the hotel. The valid values are between 1 to 5. E.g. 2

url

string

Link to the external site where you can book a hotel room

Edges

EdgeDescription

hotel_rooms

Rooms in this hotel

Validation Rules

ErrorDescription
275Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects.
100Invalid parameter

Creating

Examples

To create a catalog for Dynamic Ads for Travel, set vertical to hotels:

use FacebookAds\Object\ProductCatalog;
use FacebookAds\Object\Fields\ProductCatalogFields;
use FacebookAds\Object\Values\ProductCatalogVerticalValues;

$product_catalog = new ProductCatalog(null, <BUSINESS_ID>);

$product_catalog->setData(array(
  ProductCatalogFields::NAME => "Hotel Catalog",
  ProductCatalogFields::VERTICAL => ProductCatalogVerticalValues::HOTELS,
));

$product_catalog->create();
from facebookads.adobjects.productcatalog import ProductCatalog

product_catalog = ProductCatalog(parent_id=<BUSINESS_ID>)

product_catalog[ProductCatalog.Field.name] = 'Hotel Catalog'
product_catalog[ProductCatalog.Field.vertical] = 'hotels'

product_catalog.remote_create()
curl \
  -F 'name=Hotel Catalog' \
  -F 'vertical=hotels' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.10/<BUSINESS_ID>/product_catalogs

Then to create a hotel in the above catalog:

use FacebookAds\Object\Hotel;
use FacebookAds\Object\Fields\HotelFields;

$hotel = new Hotel(null, <PRODUCT_CATALOG_ID>);

$hotel->setData(array(
  HotelFields::HOTEL_ID => 'h_1',
  HotelFields::NAME => 'Sample Hotel',
  HotelFields::DESCRIPTION => 'hotel description',
  HotelFields::BRAND => 'hotel brand',
  HotelFields::URL => 'http://www.example.com/samplehotel',
  HotelFields::IMAGES => array(
    array(
      'image_url' => 'http://www.example.com/pic1.jpg',
      'tags' => array('front view', 'balcony'),
    ),
    array(
      'image_url' => 'http://www.example.com/pic2.jpg',
      'tags' => array('lobby view'),
    ),
  ),
  HotelFields::ADDRESS => array(
    'street_address' => '1 Hacker Way',
    'city' => 'Menlo Park',
    'region' => 'California',
    'country' => 'United States',
    'postal_code' => '94025',
    'neighborhoods' => array('Palo Alto', 'Menlo Park'),
    'latitude' => 37.484116,
    'longitude' => -122.148244,
  ),
  HotelFields::GUEST_RATINGS => array(
    array(
      'score' => 7.8,
      'rating_system' => 'sample_rating',
      'number_of_raters' => 780,
    ),
  ),
  HotelFields::STAR_RATING => 4,
  HotelFields::PHONE => '+351234123456',
));

$hotel->create();
from facebookads.adobjects.hotel import Hotel

hotel = Hotel(None, <PRODUCT_CATALOG_ID>)
hotel.update({
    Hotel.Field.hotel_id: 'h_1',
    Hotel.Field.name: 'Sample Hotel',
    Hotel.Field.description: 'hotel description',
    Hotel.Field.brand: 'hotel brand',
    Hotel.Field.url: 'http://www.example.com/samplehotel',
    Hotel.Field.images: [
        {
            'image_url': 'http://www.example.com/pic1.jpg',
            'tags': ['front view','balcony'],
        },
        {
            'image_url': 'http://www.example.com/pic2.jpg',
            'tags': ['lobby view'],
        },
    ],
    Hotel.Field.address: {
        'street_address': '1 Hacker Way',
        'city': 'Menlo Park',
        'region': 'California',
        'country': 'United States',
        'postal_code': '94025',
        'neighborhoods': ['Palo Alto', 'Menlo Park'],
        'latitude': 37.484116,
        'longitude': -122.148244,
    },
    Hotel.Field.guest_ratings: [
        {
            'score': 7.8,
            'rating_system': 'sample_rating',
            'number_of_raters': 780,
        },
    ],
    Hotel.Field.star_rating: 4,
    Hotel.Field.phone: '+351234123456',
})

hotel.remote_create()
curl \
  -F 'hotel_id=h_1' \
  -F 'name=Sample Hotel' \
  -F 'description=hotel description' \
  -F 'brand=hotel brand' \
  -F 'url=http://www.example.com/samplehotel' \
  -F 'images=[ 
    { 
      "image_url": "http:\/\/www.example.com\/pic1.jpg", 
      "tags": ["front view","balcony"] 
    }, 
    {"image_url":"http:\/\/www.example.com\/pic2.jpg","tags":["lobby view"]} 
  ]' \
  -F 'address={ 
    "street_address": "1 Hacker Way", 
    "city": "Menlo Park", 
    "region": "California", 
    "country": "United States", 
    "postal_code": "94025", 
    "neighborhoods": ["Palo Alto","Menlo Park"], 
    "latitude": 37.484116, 
    "longitude": -122.148244 
  }' \
  -F 'guest_ratings=[ 
    { 
      "score": 7.8, 
      "rating_system": "sample_rating", 
      "number_of_raters": 780 
    } 
  ]' \
  -F 'star_rating=4' \
  -F 'phone=+351234123456' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.10/<PRODUCT_CATALOG_ID>/hotels
You can make a POST request to hotels edge from the following paths:
When posting to this edge, a Hotel will be created.

Permissions

Developers usually request these permissions for this endpoint:

Marketing Apps
  • ads_management
Page management Apps
No data
Other Apps
No data

Parameters

NameDescription
address
Object

The address of the hotel

Required
city
string
Required
city_id
string
country
string
Required
latitude
float
Required
longitude
float
Required
neighborhoods
list<string>
postal_code
string
Required
region
string
Required
street_address
string
Required
applinks
Object

App links for native platforms, e.g. Android, IOS and Windows Phone.

android
ios
ipad
iphone
windows_phone
brand
string

Hotel brand

description
string

Description of the hotel

Required
guest_ratings
list<Object>

Guest ratings for this hotel.

score
float
Required
rating_system
string
Required
number_of_raters
int64
Required
hotel_id
string

A unique identifier for this hotel provided by advertiser. (i.e. from the id field in the feed

Required
images
list<Object>

Links to hotel images. Please note that carousel format utilizes a square 1:1 aspect ratio images (recommended size - 600x600px) while single hotel ad uses 1.91:1 aspect ratio image(recommended size - 1200x630px). Please provide at least one image.

Required
image_url
URL
Required
tags
list<string>
name
string

Name of the hotel

Required
phone
phone number string

Hotel's phone number

star_rating
float

The star rating of the hotel

url
URL

Link to the external site where you can book a hotel room

Required

Return Type

This endpoint supports read-after-write and will read the node represented by id in the return type.
Struct {
id: numeric string,
}
You may perform a POST request to the following edge from this node:

Validation Rules

ErrorDescription
100Invalid parameter

Updating

Examples

To update an existing hotel:

curl \
-X POST \
-F "guest_ratings= [ \
  {'score':9.5, 'rating_system':'rating_system', 'number_of_raters':1500} \
]" \
-F "star_rating=5" \
-F "access_token=<ACCESS_TOKEN>" \
https://graph.facebook.com/<API_VERSION>/<HOTEL_ID>
You can update a Hotel by making a POST request to /{hotel_id}.

Permissions

Developers usually request these permissions for this endpoint:

Marketing Apps
  • ads_management
Page management Apps
No data
Other Apps
No data

Parameters

NameDescription
address
Object

The address of the hotel

city
string
Required
city_id
string
country
string
Required
latitude
float
Required
longitude
float
Required
neighborhoods
list<string>
postal_code
string
Required
region
string
Required
street_address
string
Required
applinks
Object

App links for native platforms, e.g. Android, IOS and Windows Phone.

android
ios
ipad
iphone
windows_phone
brand
string

Hotel brand

description
string

Description of the hotel

guest_ratings
list<Object>

Guest ratings for this hotel.

score
float
Required
rating_system
string
Required
number_of_raters
int64
Required
images
list<Object>

Links to hotel images. Please note that carousel format utilizes a square 1:1 aspect ratio images (recommended size - 600x600px) while single hotel ad uses 1.91:1 aspect ratio image(recommended size - 1200x630px). Please provide at least one image.

image_url
URL
Required
tags
list<string>
name
string

Name of the hotel

phone
phone number string

Hotel's phone number

star_rating
float

The star rating of the hotel

url
URL

Link to the external site where you can book a hotel room

Return Type

This endpoint supports read-after-write and will read the node to which you POSTed.
Struct {
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter

Deleting

You can delete a Hotel by making a DELETE request to /{hotel_id}.

Parameters

This endpoint doesn't have any parameters.

Return Type

Struct {
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter