GET
# OpenTable URL to Restaurant ID API

Turn a full OpenTable `/r/{slug}` profile URL into the stable restaurant ID used by reviews and availability.

## Overview

#### Exact match for any profile URL

Any valid OpenTable /r/{slug} profile URL resolves to its exact restaurant, including older URLs whose slug no longer matches the current restaurant name or location.

Use this endpoint when your input is an OpenTable restaurant URL instead of a numeric ID. The response also includes enough location context to verify the match before using `restaurant_id` with reviews, exact availability, or nearby slots.

### Endpoint URL

GET https://api.stayapi.com/v1/opentable/restaurant/url-to-id 

## Query Parameter

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| url | string | Required | Full OpenTable restaurant profile URL in the form `https://www.opentable.com/r/{slug}`. Country domains such as `opentable.fr` and `opentable.co.uk` are supported. |

## Response Fields

| Field | Description |
| --- | --- |
| restaurant\_id | Positive numeric OpenTable restaurant ID. |
| name | Restaurant name returned by OpenTable. |
| country | Country associated with the matched restaurant. |
| macro | OpenTable's broader dining area, such as South West London. |
| neighborhood | OpenTable neighborhood when available. |

#### Keep the ID

Store restaurant\_id after the first resolution. Future review and availability calls can use it directly without repeating the URL lookup.

## Error Responses

Errors follow RFC 7807 Problem Details with `provider: "opentable"` and `product: "url-to-id"`.

### 400 Invalid URL

`INVALID_URL` when the value is not a supported OpenTable restaurant profile URL.

### 404 Restaurant not found

`RESTAURANT_NOT_FOUND` when no OpenTable restaurant exists at that profile URL.

### 502 Upstream error

`UPSTREAM_ERROR` when OpenTable can't be reached or doesn't return the restaurant profile.

## Related Endpoints

### Restaurant Menu

Fetch structured menus and prices with the resolved ID.

[View Documentation →](/docs/endpoints/opentable/menu)

### Restaurant Reviews

Fetch newest, highest-rated, or lowest-rated reviews with the resolved ID.

[View Documentation →](/docs/endpoints/opentable/restaurant-reviews)

### Exact Availability

Check one restaurant, date, time, and party size.

[View Documentation →](/docs/endpoints/opentable/availability)

Request

```curl
curl -G "https://api.stayapi.com/v1/opentable/restaurant/url-to-id" \
  --data-urlencode "url=https://www.opentable.com/r/the-ivy-victoria-brasserie-london-2" \
  -H "X-API-Key: YOUR_API_KEY"
```

Response

```json
{
  "success": true,
  "restaurant_id": 180654,
  "name": "The Ivy Victoria Brasserie",
  "country": "United Kingdom",
  "macro": "South West London",
  "neighborhood": "Victoria"
}
```

```json
{
  "type": "https://api.stayapi.com/errors/invalid-url",
  "title": "Invalid OpenTable URL",
  "status": 400,
  "detail": "url must be a full OpenTable restaurant URL in the form https://www.opentable.com/r/{slug}.",
  "instance": "/v1/opentable/restaurant/url-to-id",
  "provider": "opentable",
  "product": "url-to-id",
  "error_code": "INVALID_URL",
  "correlation_id": "request-id"
}
```
