Get the URL of a chat room

Update time: 2022/12/13 08:33:31

After creating a chat room, you can request the address of the chat room by calling the server API (recommended) or calling the corresponding API of the SDK to establish a persistent connection to the chat room.

Request URL

httpPOST https://api.netease.im/nimserver/chatroom/requestAddr.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

Request parameters

  • For information about how to set the header in a POST request, see API Call methods.

  • The settings of the body in a POST request:

ParameterTypeRequiredDescription
roomid longYes Chat room ID
accidStringYes Account that joins a chat room
clienttype int No 1: weblink (web client); 2: commonlink (Non-web client); 3: wechatlink (WeChat Mini Program). Default value: 1
clientipStringNoClient IP address. If you specify the client IP address, a link of the chat room closest to the region where the IP address is located will be returned.

Example

cURL request

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451217708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&accid=zhangsan&clienttype=1' 'https://api.netease.im/nimserver/chatroom/requestAddr.action'

Example response

Example success response

json"Content-Type": "application/json; charset=utf-8"
{
  "addr": [
    "testchat.netease.im:6666",
    "testchat.netease.im:8888"
  ],
  "code": 200
}

Status codes

The status code is returned in the response body. For more information, see Status codes.

Was this page helpful?
Yes
No
  • Request URL
  • Request parameters
  • Example
  • cURL request
  • Example response
  • Status codes