GET
# URL to Hotel ID

Convert Agoda hotel URLs to their numeric hotel IDs.

## Overview

The URL to Hotel ID endpoint extracts the numeric hotel ID from an Agoda hotel URL. Use it whenever you have a hotel URL from a user or another source and need the numeric ID to call other Agoda endpoints like hotel reviews.

### Endpoint URL

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

### Use Case

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

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| url | string | Required | Full Agoda hotel URL (see accepted formats below) |

### Accepted URL Formats

- 1

Hotel detail URL

`https://www.agoda.com/<slug>/hotel/<city>-<country>.html`
- 2

Hotel detail URL with `/all/` segment

`https://www.agoda.com/<slug>/hotel/all/<city>-<country>.html`

Note: Query strings and fragments are stripped before lookup.

## Response Fields

| Field | Type | Description |
| --- | --- | --- |
| hotel\_id | integer | The numeric Agoda hotel ID |
| url | string | The normalized Agoda URL (query string and fragment removed) |

## 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/agoda/hotel/url-to-id?url=https://www.agoda.com/oulu-hotelli-apartments/hotel/all/oulu-fi.html 

2. 2

#### Use Hotel ID for Reviews

Pass the returned `hotel_id` to the reviews endpoint.

 GET /v1/agoda/hotel/reviews/356812 

**Note:** Cache hotel IDs on your end for frequently accessed hotels. The numeric ID never changes for a given hotel.

For a date-free property profile, pass the resolved `hotel_id` to [hotel details](/docs/endpoints/agoda/hotel-details).

## Related Endpoints

[ 

### Hotel Reviews

Fetch Agoda reviews for a hotel by its numeric ID

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

### Review Comments

Fetch reviews from a specific review provider for a hotel

 ](/docs/endpoints/agoda/hotel-review-comments)

Request

```curl
curl -X GET "https://api.stayapi.com/v1/agoda/hotel/url-to-id?url=https://www.agoda.com/oulu-hotelli-apartments/hotel/all/oulu-fi.html" \
  -H "x-api-key: YOUR_API_KEY"
```

Response

```json
{
  "hotel_id": 356812,
  "url": "https://www.agoda.com/oulu-hotelli-apartments/hotel/all/oulu-fi.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": "agoda",
  "provided_url": "https://www.agoda.com/"
}
```
