> ## Documentation Index
> Fetch the complete documentation index at: https://tiktools.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Room ID

> Resolve a TikTok username to their current live room ID. The server resolves the unique_id to a room_id on your behalf - no client-side HTML scraping needed.

## `POST` `/webcast/room_id`

Resolve a TikTok username to their current live room ID. The server resolves the `unique_id` to a `room_id` on your behalf - no client-side HTML scraping needed.

**How it works:** The server checks its cache first (30-minute TTL). For Pro/Ultra/Admin tiers, resolution uses a residential proxy for reliable results. For other tiers, the server attempts direct resolution (may fail from datacenter IPs).

**Response data:** Returns `unique_id`, `room_id`, `alive` (whether the user is currently live), and `cached` (whether the result came from server cache). Use the returned `room_id` with other endpoints like `sign_websocket`, `rankings`, `gift_info`, etc.

**Use cases:** When you only have a username and need the `room_id` for other API calls. Many endpoints accept `unique_id` directly, but some (like `sign_websocket`) require the room ID. This endpoint eliminates the need for client-side TikTok page scraping.

### Parameters

| Parameter   | Type   | Required | Description                 |
| ----------- | ------ | -------- | --------------------------- |
| `unique_id` | string | Yes      | TikTok username (without @) |

### Response

```json theme={null}
{ "status_code": 0, "data": { "unique_id": "username", "room_id": "7123456789", "alive": true, "cached": false } }
```

### Examples

<CodeGroup>
  ```javascript Node.js theme={null}
  const res = await fetch('https://api.tik.tools/webcast/room_id?apiKey=YOUR_KEY', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ unique_id: 'username' })
  });
  const { data } = await res.json();
  console.log(`Room ID: ${data.room_id}, Live: ${data.alive}`);
  ```

  ```python Python theme={null}
  import requests
  res = requests.post('https://api.tik.tools/webcast/room_id',
      params={'apiKey': 'YOUR_KEY'},
      json={'unique_id': 'username'})
  data = res.json()['data']
  print(f"Room ID: {data['room_id']}, Live: {data['alive']}")
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.tik.tools/webcast/room_id?apiKey=YOUR_KEY" \\
    -H "Content-Type: application/json" \\
    -d '{"unique_id": "username"}'
  ```

  ```java Java theme={null}
  HttpClient client = HttpClient.newHttpClient();
  String json = "{\\"unique_id\\": \\"username\\"}";
  HttpRequest req = HttpRequest.newBuilder()
      .uri(URI.create("https://api.tik.tools/webcast/room_id?apiKey=YOUR_KEY"))
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();
  HttpResponse<String> res = client.send(req, HttpResponse.BodyHandlers.ofString());
  System.out.println(res.body());
  ```

  ```go Go theme={null}
  payload := bytes.NewBufferString(`{"unique_id":"username"}`)
  resp, err := http.Post(
      "https://api.tik.tools/webcast/room_id?apiKey=YOUR_KEY",
      "application/json", payload)
  if err != nil { log.Fatal(err) }
  defer resp.Body.Close()
  body, _ := io.ReadAll(resp.Body)
  fmt.Println(string(body))
  ```

  ```csharp C# theme={null}
  using var client = new HttpClient();
  var json = new StringContent(
      @"{""unique_id"":""username""}",
      Encoding.UTF8, "application/json");
  var res = await client.PostAsync(
      "https://api.tik.tools/webcast/room_id?apiKey=YOUR_KEY", json);
  Console.WriteLine(await res.Content.ReadAsStringAsync());
  ```
</CodeGroup>
