GET
# URL to Hotel ID

Convert Booking.com hotel URLs or slugs to their numeric hotel IDs.

## Overview

#### Response Time

This endpoint extracts data from the live Booking.com page, so it is slower than ID-based endpoints.

The URL to Hotel ID endpoint extracts the numeric hotel ID from any Booking.com hotel URL or slug. This is useful when you have a hotel URL but need the numeric ID for other API calls like the reviews endpoint.

### Endpoint URL

GET https://api.stayapi.com/v1/booking/hotel/url-to-id 

### Use Case

Use this endpoint when you have a Booking.com hotel URL (from a user or another source) and need to get the numeric hotel ID for use with other endpoints.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| url | string | Required | Booking.com hotel URL or slug in any of the accepted formats (see below) |

### Accepted URL Formats

- 1

Full URL

`https://www.booking.com/hotel/th/baan-coconut.html`
- 2

Country code + slug

`th/baan-coconut`
- 3

Just the slug

`baan-coconut`

Note: Assumes Thailand (th) as default country

## Response Fields

| Field | Type | Description |
| --- | --- | --- |
| hotel\_id | string | The numeric Booking.com hotel ID |
| url | string | The normalized full Booking.com URL |

## Common Workflow

### URL to Reviews Flow

1. 1

#### Get Hotel ID from URL

Call this endpoint with the hotel URL to get the numeric ID.

 GET /v1/booking/hotel/url-to-id?url=th/baan-coconut 

2. 2

#### Use Hotel ID for API Calls

Use the returned `hotel_id` with other endpoints.

 GET /v1/booking/hotel/reviews?url=https://www.booking.com/hotel/th/baan-coconut.html 

**Note:** URL resolution fetches the live page, so it is slower than ID-based calls. Cache hotel IDs on your end for frequently accessed hotels.

## Related Endpoints

[ 

### Hotel Reviews

Get reviews for a hotel using its URL

 ](/docs/endpoints/booking/hotel-reviews)[ 

### Hotel Details

Get detailed information about a hotel

 ](/docs/endpoints/booking/hotel-details)

Request

```curl
curl -X GET "https://api.stayapi.com/v1/booking/hotel/url-to-id?url=th/baan-coconut" \
  -H "x-api-key: YOUR_API_KEY"
```

Response

```json
{
  "hotel_id": "1302021",
  "url": "https://www.booking.com/hotel/th/baan-coconut.html"
}
```

```json
{
  "type": "https://api.stayapi.com/errors/not-found",
  "title": "Hotel ID Not Found",
  "status": 404,
  "detail": "Could not extract hotel ID from the provided URL",
  "error_code": "NOT_FOUND",
  "provider": "booking",
  "provided_url": "invalid-hotel-slug"
}
```
