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

# 批量获取用户 IM 地址

> 批量获取多个用户的 IM 连接地址

## 概述

批量获取多个用户的 IM 连接地址，用于为不同用户分配不同的连接节点。

## 查询参数

<ParamField query="intranet" type="integer" default={0}>
  是否返回内网地址

  * `0` - 返回外网地址
  * `1` - 返回内网地址
</ParamField>

## 请求体

<ParamField body="uids" type="array" required>
  用户 ID 数组

  <ParamField body="uids[]" type="string">
    用户 ID
  </ParamField>
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "http://localhost:5001/route/batch?intranet=0" \
    -H "Content-Type: application/json" \
    -d '["user1", "user2", "user3"]'
  ```

  ```javascript JavaScript theme={null}
  const userIds = ["user1", "user2", "user3"];

  const response = await fetch('http://localhost:5001/route/batch?intranet=0', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(userIds)
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  user_ids = ["user1", "user2", "user3"]

  response = requests.post(
      'http://localhost:5001/route/batch',
      params={'intranet': 0},
      json=user_ids
  )

  data = response.json()
  print(data)
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      userIds := []string{"user1", "user2", "user3"}
      jsonData, _ := json.Marshal(userIds)
      
      resp, err := http.Post(
          "http://localhost:5001/route/batch?intranet=0",
          "application/json",
          bytes.NewBuffer(jsonData),
      )
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()
      
      var result []map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      fmt.Printf("%+v\n", result)
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 成功响应 theme={null}
  [
    {
      "uids": ["user1", "user2"],
      "tcp_addr": "127.0.0.1:5100",
      "ws_addr": "ws://127.0.0.1:5200",
      "wss_addr": "wss://127.0.0.1:5300"
    },
    {
      "uids": ["user3"],
      "tcp_addr": "127.0.0.1:5101",
      "ws_addr": "ws://127.0.0.1:5201",
      "wss_addr": "wss://127.0.0.1:5301"
    }
  ]
  ```
</ResponseExample>

## 响应字段

响应是一个数组，每个元素包含以下字段：

<ResponseField name="uids" type="array" required>
  分配到此地址的用户 ID 列表
</ResponseField>

<ResponseField name="tcp_addr" type="string" required>
  TCP 连接地址，格式为 `host:port`
</ResponseField>

<ResponseField name="ws_addr" type="string" required>
  WebSocket 连接地址，格式为 `ws://host:port`
</ResponseField>

<ResponseField name="wss_addr" type="string" required>
  WebSocket Secure 连接地址，格式为 `wss://host:port`
</ResponseField>

## 状态码

| 状态码 | 说明             |
| --- | -------------- |
| 200 | 成功获取批量 IM 连接地址 |
| 400 | 请求参数错误         |
| 500 | 服务器内部错误        |
