Chat Room

Update time: 2022/11/25 08:17:29

Creating a chat room

Creates a chat room.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
creatorStringYesAccount accid of the chat room owner
nameStringYesChat room name, with up to 128 characters
announcementStringNoAnnouncement, with up to 4096 characters
broadcasturlStringNoLive streaming address, with up to 1024 characters
extStringNoExtension field, with up to 4096 characters
queuelevelintNoQueue management permission: 0: Everyone can modify the queue, 1: Only the anchor administrator can modify the queue. 0 is the default

curl request example

curlcurl -X POST -H "CheckSum: fc040248923c881f2fe7cc39602b79565230155c" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451217360" -H "Content-Type: application/x-www-form-urlencoded" -d 'name=mychat room&announcement=&broadcasturl=xxxxxx&creator=zhangsan' 'https://api.netease.im/nimserver/chatroom/create.action'

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "chat room": {
    "roomid": 66,
    "valid": true,
    "announcement": null,
    "name": "mychat room",
    "broadcasturl": "xxxxxx",
    "ext": "",
    "creator": "zhangsan"
  },
  "code": 200
}

Valid status codes

200、403、414、416、419、431、500

See Status codes .


Querying the chat room profile

Queries the chat room profile.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
needOnlineUserCountStringNoWhether to return the number of online users, true or false, the default is false

curl request example

curlcurl -X POST -H "CheckSum: fc040248923c881f2fe7cc39602b79565230155c" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451217360" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&needOnlineUserCount=true' 'https://api.netease.im/nimserver/chatroom/get.action'

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
  "chat room": {
    "roomid": 66,
    "valid": true,
    "muted":false, //Whether the chat room is in the state of all muted, meaning only the administrator and owner can speak 
    "announcement": null,
    "name": "mychat room",
    "broadcasturl": "xxxxxx",
    "onlineusercount": 1,
    "ext": "",
    "creator": "zhangsan",
    "queuelevel": 0,
    "ionotify": true // Whether chat room entry and leave notification is enabled
  },
  "code": 200
}

Valid status codes

200、403、404、414、416、431、500

See Status codes .


Query chat room profiles

Queries multiple chat room profiles at a time.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidsStringYesMultiple roomids in the format: ["6001","6002","6003"] (accid corresponding to JSONArray, parsing error results in code 414), limited to 20 roomids
needOnlineUserCountStringNoWhether to return the number of online users, true or false, the default is false

curl request example

curlcurl -X POST -H "CheckSum: fc040248923c881f2fe7cc39602b79565230155c" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451217360" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomids=["6001","6002","6003"]&needOnlineUserCount=true' 'https://api.netease.im/nimserver/chatroom/getBatch.action'

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
    "noExistRooms": [//ID list of chat rooms that do not exist
        6001
    ],
    "succRooms": [
        {
            "roomid": 6002,
            "valid": true,
            "announcement": "hi,this is announcement",
            "muted": false,
            "name": "6002 chat room",
            "broadcasturl": "",
            "onlineusercount": 0,
            "ext": "6002 ext",
            "creator": "zhangsan",
            "queuelevel": 0,
    				"ionotify": true // Whether chat room entry and leave notification is enabled
        }
    ],
    "failRooms": [//IDs of chat rooms that have failed, possible reasons include return of error code 500 in verification
	6003
    ],
    "code": 200
}

Valid status codes

200、403、404、414、416、431、500

See Status codes .


Updating chat room information

Updates a chat room profile.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
nameStringNoChat room name, with up to 128 characters
announcementStringNoAnnouncement, with up to 4096 characters
broadcasturlStringNoLive streaming address, with up to 1024 characters
extStringNoExtension field, the length of which is limited to 4096 characters
needNotifyStringNotrue or false, whether to send update notification events, the default is true
notifyExtStringNoExtension field of notification event, the length of which is limited to 2048
queuelevelintNoQueue management permission: 0: Everyone can modify the queue, 1: Only the anchor administrator can modify the queue.

curl request example

curlcurl -X POST -H "CheckSum: 95a26060d002a473057a71cb7d949d6e91d6d167" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451214690" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&name=mynewchat room&announcement=mynewchat room' 'https://api.netease.im/nimserver/chatroom/update.action'

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
  "chat room": {
    "roomid": 66,
    "valid": true,
    "announcement": "This is a chat room",
    "name": "mychat room",
    "broadcasturl": "xxxxxx",
    "ext": "",
    "creator": "zhangsan"
  },
  "code": 200
}

Valid status codes

200, 403, 404, 414, 416, 431, 500, 13002

See Status codes .


Changing the on/off status

Changes the on/off status of a chat room.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
operatorStringYesOperator account, can only be operated by the creator
validStringYestrue or false, false: close chat room; true: open chat room

curl request example

curlcurl -X POST -H "CheckSum: 95a26060d002a473057a71cb7d949d6e91d6d167" -H "AppKey: f1234540c12345673123456847aaaaaa" -H "Nonce: 1" -H "CurTime: 1451214690" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&operator=zhangsan&valid=true' 'https://api.netease.im/nimserver/chatroom/toggleCloseStat.action'

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "roomid": 13,
    "valid": true,
    "announcement": "This is a chat room",
    "name": "myChat room",
    "broadcasturl": "http://www.xxxx.com/xxxxxx",
    "ext": "",
    "creator": "zhangsan"
  },
  "code": 200
}

Valid status codes

200, 403, 404, 414, 416, 417, 419, 431, 500

See Status codes .


Setting user roles in the chat room

Sets user roles in the chat room.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
operatorStringYesoperator account accid
targetStringYesaccount of the operated accid
optintYesoperation:
1: Set as administrator, operator must be owner
2: set as normal user, the operator must be owner or administrator
-1: set as blocklisted user, the operator must be owner or administrator
-2: Set as muted user, operator must be owner or administrator
optvalueStringYestrue or false, true: set; false: unset;
After executing "unset", members not in the mute list or blocklist will become visitors
notifyExtStringNoNotification extension field, with a length limited to 2048, json format is recommended

curl request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&operator=zhangsan&target=lisi&opt=2&optvalue=true' 'https://api.netease.im/nimserver/chatroom/setMemberRole.action'

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "roomid": 16,
    "level": 10,
    "accid": "zhangsan",
    "type": "COMMON"
  },
  "code": 200
}

Note:
The type field returned may be:
        LIMITED, //restricted user, blocklist + mute 
        COMMON, //ordinary fixed member
        CREATOR, //owner 
        administrator, // administrator 
        TEMPORARY, //temporary user, non-fixed member

Valid status codes

200, 403, 404, 414, 416, 417, 419, 431, 500, 13002

See Status codes .


Requesting the URL address of a chat room

Requests the URL address and token of a 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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
accidStringYesAccount of user joining chat room
clienttypeintNo1: weblink (used if client is web); 2: commonlink (used if client is non-web); 3: wechatlink (for WeChat applet), the default is 1
clientipStringNoClient ip, when this parameter is passed, an appropriate address will be returned based on the region of user ip

curl request example

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'

Response

The data returned in the HTTP response is in JSON format.

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

Valid status codes

200, 403, 414, 416, 431, 500, 514, 13002

See Status codes .


Sending messages

Request URL

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

For information about headers in the request, see Overview.

Send messages in the chat room

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
msgIdStringYesclient message id, using random strings such as uuid, messages with the same msgId will be deduplicated by the client
fromAccidStringYesAccount of the message sender accid
msgTypeintYesMessage type:
0: indicates text message,
1: indicates image,
2: indicates audio,
3: indicates video,
4: indicates geographic location information,
6: indicates file,
10: indicates Tips message,
100: Custom message type (Special attention, for applications without activated GuardEase anti-spam feature, this type of message will not be submitted to anti-spam filtering)
subTypeintNoCustom message subtype, greater than 0
resendFlagintNoResend tag, 0: non-resend, 1: Resend. If the message is resent, deduplication logic check based on msgid will be performed
attachStringNoText message: complete the message copy;
For other types of messages, see message format example;
Length limit is 4096 characters
extStringNoMessage extension field, the content can be customized, JSON format should be preferred, with a length limit of 4096 characters
skipHistoryintNoWhether to skip storing cloud history, 0: Don't skip, save the message history; 1: Skip, no history is saved on the cloud; the default is 0
abandonRatiointNoOptional, the probability of message abandonment. Value range [0-9999];
0 indicates no message is abandoned, 9999 indicates 99.99% probability of abandoning the message, and 0 is the default;
Note that if this parameter is not blank, the highPriority parameter below will be invalid;
This parameter can be used to control the message flow of a specific service type.
highPriorityBooleanNoOptional, true indicates high-priority message, which will be given priority by CommsEase in terms of delivery; false indicates low-priority message. The default is false.
It is strongly recommended to apply appropriate parameters to ensure the delivery of high-priority in-app messages when necessary. Only applying high priority equals no priority. A one-to-one chat room supports up to 10 high priority messages per second, and those in excess will be deemed as normal messages. High priority messages can be re-sent upon joining. See needHighPriorityMsgResend parameter
needHighPriorityMsgResendBooleanNoOptional, true indicates that the message will be resent, and false indicates that the message will not be resent. The default is true. Note: If set to true, when the user rejoins the chat room after leaving, the message sent will still be received by the user, provided the validity period is not expired by then. The current default validity period is 30s. NeedHighPriorityMsgResend does not take effect if highPriority is not configured.
useYiDunintNoOptional, whether to use GuardEase for anti-spam on a message, the optional value is 0.
0: (if GuardEase is activated) Do not use GuardEase for anti-spam but general anti-spam, custom messages included.

No input in the field indicates by default that GuardEase anti-spam feature, if enabled on the app, will be used to distinguish spam messages
yidunAntiCheatingStringNoOptional, a field exclusive to GuardEase anti-spam enhanced anti-cheating, limited to json with up to 1024 characters (For details, see GuardEase Anti-Spam interface document - exclusive field for anti-spam and anti-section-sweeping)
bidStringNoOptional, anti-spam service ID, used to implement "anti-spam configuration for a message", if left empty, then the original anti-spam configuration applies
antispamStringNoFor applications with activated GuardEase antispam feature, specify if the message contents should go through GuardEase detection (antispamCustom)?
true or false, the default is false.
Only valid for messages of type: 100 custom message.
notifyTargetTagsStringNoOptional, tag expression, up to 128 characters
antispamCustomStringNoIt takes effect when the antispam parameter is set to true.
User-defined anti-spam detection content, in JSON format, length is limited to 5000 characters (the same as body field). antispamCustom should be in the format as follows:

{"type":1,"data":"custom content"}

Field description:
1. type: 1: text, 2: image.
2. data: Text content or image address.
envStringNoOwning environment, depending on env, you can configure different message delivery for addresses

curl request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&fromAccid=zhangsan&msgType=0&attach=This+is+test+msg&msgId=c9e6c306-804f-4ec3-b8f0-573778829419' 'https://api.netease.im/nimserver/chatroom/sendMsg.action'

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "code":200,
  "desc":{
    "time": "1456396333115", 
    "fromAvator":"http://b12026.nos.netease.com/MTAxMTAxMA==/bmltYV84NDU4OF8xNDU1ODczMjA2NzUwX2QzNjkxMjI2LWY2NmQtNDQ3Ni0E2LTg4NGE4MDNmOGIwMQ==",
    "msgid_client": "c9e6c306-804f-4ec3-b8f0-573778829419",
    "fromClientType": "REST",
    "attach": "This+is+test+msg",
    "roomId": "36",
    "fromAccount": "zhangsan",
    "fromNick": "Zhang San",
    "type": "0",
    "ext": "",
    "highPriorityFlag":1, //High priority message flag, not having this flag indicates non-high priority
    "msgAbandonFlag":"1" //Flag for abandoning message, returned only when the abandonRatio parameter is passed. If this flag is not returned, it indicates the message is not abandoned.
  } 
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Adding a chatbot to the chat room

Adds a chatbot to the chat room. The chatbot expires in 24 hours.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
accidsJSONArrayYesAccid list of robot accounts, which must be valid account, 100 accounts in maximum
roleExtStringNoRobot information extension field, recommended to be in json format with a length of 4096 characters
notifyExtStringNoExtension field for notification about robot joining the chat room, recommended to be in json format with a length of 2048 characters

curl request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&accids=["zhangsan","lisi"]' 'https://api.netease.im/nimserver/chatroom/addRobot.action'

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "failAccids": "[\"hzzhangsan\"]",
    "successAccids": "[\"hzlisi\"]",
    "oldAccids": "[\"hzwangwu\"]"
  },
  "code": 200
}

Valid status codes

200, 403, 414, 416, 417, 419, 431, 500, 13003

See Status codes .


Deleting a chatbot from the chat room

Deletes a chatbot from the chat room.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
accidsJSONArrayYesAccid list of robot accounts, which must be valid account, 100 accounts in maximum

curl request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&accids=["zhangsan","lisi"]' 'https://api.netease.im/nimserver/chatroom/removeRobot.action'

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "failAccids": "[\"hzzhangsan\"]",
    "successAccids": "[\"hzlisi\"]"
  },
  "code": 200
}

Valid status codes

200, 403, 404, 414, 416, 419, 431, 500

See Status codes .


Deleting chatbots

Deletes all chatbots from a chat room.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
notifybooleanNoWhether to send the message of leave chat room notification, the default is false

curl request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&notify=false' 'https://api.netease.im/nimserver/chatroom/cleanRobot.action'

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
    "code": 200,
    "desc": {
        "size": 2
    }
}

Valid status codes

200, 403, 414, 416, 500

See Status codes .


Setting temporary mute status

Mutes the members in the chat room temporarily.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
operatorStringYesOperator accid, must be administrator or creator
targetStringYesAccount accid of muted target
muteDurationlongYes0: unmute; >0 set mute time (in seconds), max. 2592000 seconds (30 days)
needNotifyStringNoWhether broadcast is needed upon completion of operation, true or false, the default is true
notifyExtStringNoThe extension field of notification broadcast event, with a length limited to 2048 characters

curl request example

curlcurl -X POST -H "CheckSum: 66dc1ad0166a37037abcdfeb749bhh049c937777" -H "AppKey: acd7y640c85j8kf734219e1847aggggg" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=123&operator=zhangsan&target=lisi&muteDuration=300&notifyExt=This is an extension field' "https://api.netease.im/nimserver/chatroom/temporaryMute.action"

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "muteDuration": 300
  },
  "code": 200
}

Valid status codes

200, 403, 404, 414, 416, 417, 419, 431, 500, 13002

See Status codes .


Muting all members in the chat room

Mutes all members in the chat room. In this case, only the owner and administrator can send messages.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
operatorStringYesOperator accid, must be administrator or creator
muteStringYestrue or false
needNotifyStringNotrue or false, the default is true
notifyExtStringNoNotification extension field

curl request example

curlcurl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=4235&operator=zhangsan&mute=true' "https://api.netease.im/nimserver/chatroom/muteRoom.action"

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "success": true
  },
  "code": 200
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Querying TOP N indicators in a chat room

Request URL

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

For information about headers in the request, see Overview.

1. Top N list of chat room related indicators are listed by specified period based on timestamp

2. The statistics of the current day can be queried on the next day

3. Only statistics for the last 30 days can be queried

Parameters

ParameterTypeRequiredDescription
topnintNoTop N value, in the range of 1~500, default is 100
timestamplongNoTime coordinate point of the index to be queried. If not provided, the current time is the default, in the unit of either second or millisecond
periodStringNoStatistical period, optional values include hour/day, hour is the default
orderbyStringNoTake the sort value, optional values include active/join/message, which indicates sort by daily activity, by entry person-time and by number of messages respectively, the default is active

curl request example

curlcurl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'timestamp=1471781873&period=hour&topn=3&orderby=join'  "https://api.netease.im/nimserver/stats/chatroom/topn.action"

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "code": 200,
  "data": [
    {
      "activeNums": 5955, // number of active users in the chat room
      "datetime": 1471712400, // The statistical time point, in seconds, should be 0:00 of the day for statistics by day; or the specified whole hour of the day for statistics by hour
      "joinNums": 18621, // number of entry person-times
      "msgs": 2793, //number of messages occurred in the chat room
      "period": "HOUR", // Statistical period, HOUR indicates hourly statistics; DAY indicates daily statistics
      "roomId": 3571337 // Chat room ID
    },
    {
      "activeNums": 6047,
      "datetime": 1471708800,
      "joinNums": 15785,
      "msgs": 2706,
      "period": "HOUR",
      "roomId": 3573737
    },
    {
      "activeNums": 5498,
      "datetime": 1471708800,
      "joinNums": 14590,
      "msgs": 2258,
      "period": "HOUR",
      "roomId": 3513774
    }
  ]
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Getting a paginated list of members

Gets a paginated list of members

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
typeintYesType of members to be queried, 0: fixed member; 1: non-fixed member; 2: on-line fixed member
endtimelongYesIn milliseconds, the timestamp of the last member based on reverse chronological order, 0 represents current system time
limitlongYesNumber of returned entries, <=100d>

curl request example

curlcurl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=4235&type=0&endtime=0&limit=20'  "https://api.netease.im/nimserver/chatroom/membersByPage.action"

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "data": [
       {
          "roomid": 111,
          "accid": "abc",
          "nick": "abc",
          "avator": "http://nim.nos.netease.com/MTAxMTAwMg==/bmltYV8xNzg4NTA1NF8xNDU2Mjg0NDQ3MDcyX2E4NmYzNWI5LWRhYWEtNDRmNC05ZjU1LTJhMDUyMGE5MzQ4ZA==",
          "ext": "ext",
          "type": "administrator",
          "level": 2,
          "onlineStat": true,
          "joinTime": 1487145487971,
          "Blocklisted": true,
          "muted": true,
          "tempMuted": true,
          "tempMuteTtl": 120,
          "isRobot": true,
          "robotExpirAt":120
       }
    ]
  },
  "code": 200
}

Response

FieldTypeDescription
roomidlongChat room ID
accidStringuser accid
nickStringdisplay name shown in a chat room
avatorStringprofile picture shown in a chat room
extStringdeveloper extension field
typeStringRole type:
UNSET (not set),
LIMITED (restricted user, blocklisted or muted),
COMMON (ordinary fixed member),
owner (creator),
administrator (administrator),
TEMPORARY (temporary user, non-fixed member)
levelintMember level (absent if member level not set)
onlineStatBooleanonline or not.
joinTimelongTime point of joining a chat room
BlocklistedBooleanBlocklisted or not (absent if not blocklisted)
mutedBooleanmuted or not (absent if not muted)
tempMutedBooleantemporarily muted or not (absent if not temporarily muted)
tempMuteTtllongThe duration of the temporary mute, in seconds (absent if not temporarily muted)
isRobotBooleanWhether it is a chat room robot (absent if not a chatbot)
robotExpirAtintThe duration of robot failure, in seconds (absent if not a chatbot)
#### Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Get mutiple online member profiles at a time

Gets online member profiles at a time.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
accidsJSONArrayYes\["abc","def"\], account list, with up to 200 entries

curl request example

curlcurl -X POST -H "CheckSum: 32dc17d0190f37037abc9feb749bbf049c9367e7" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=4235&accids=["abc","def"]' "https://api.netease.im/nimserver/chatroom/queryMembers.action"

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "data": [
      {
        "roomid": 111,
        "accid": "abc",
        "nick": "cba",
        "type": "CREATOR", //COMMON: ordinary members (fixed member); CREATOR: chat room creator; administrator: chat room administrator; TEMPORARY: temporary user (non-fixed member); ANONYMOUS: anonymous user (no registered account); LIMITED: Restricted user (blocklist + mute)
        "onlineStat": true
      }
    ]
  },
  "code": 200
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Changing user profiles in a chat room

Changes user profiles in a chat room.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room ID
accidStringYesaccid requiring role information change
savebooleanNoWhether the changed information needs to be persisted, the default is false, which only takes effect for fixed members of the chat room
needNotifybooleanNoWhether notification is needed
notifyExtStringNoNotification content, with a length limit of 2048
nickStringNoChat room role information: profile name, with no more than 64 characters
avatorStringNoChat room role information: profile picture
extStringNoChat room role information: developer extension field

curl request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: he516640c8e8a72734219eh847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&accid=hzyangfeng201403&save=true&needNotify=true&nick=myNick' "https://api.netease.im/nimserver/chatroom/updateMyRoomRole.action"

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "code": 200
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Querying the list of chat rooms created by users

Updates multiple queue elements in a chat room at a time.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
creatorStringYesaccid of Chat room creator

curl request example

curlcurl -X POST -H 'appkey: fe416640c8e8a72734219e1847ad2547' -H 'cache-control: no-cache' -H 'checksum: 18f5435a7bf287af9150ad608797f75265495034' -H 'content-type: application/x-www-form-urlencoded'  -H 'curtime: 1508481877'  -H 'nonce: 12345' -d 'creator=xiaoming01' "https://api.netease.im/nimserver/chatroom/queryUserRoomIds.action"

Response

The data returned in the HTTP response is in JSON format.

json
"Content-Type": "application/json; charset=utf-8"
{
  "code": 200,
  "desc":{
    "roomids": [
        "1015",
        "2016",
        "2017",
        "5062",
        "23037398"
    ]
    }
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Turning off notifications for joining or leaving specified chat rooms

Turns off notifications for joining or leaving specified chat rooms.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room id
closebooleanYestrue/false, whether to turn off entry and leave notifications

curl request example

curlcurl -X POST -H 'appkey: fe416640c8e8a72734219e1847ad2547' -H 'cache-control: no-cache' -H 'checksum: 18f5435a7bf287af9150ad608797f75265495034' -H 'content-type: application/x-www-form-urlencoded'  -H 'curtime: 1508481877'  -H 'nonce: 12345' -d 'close=false&roomid=3001' "https://api.netease.im/nimserver/chatroom/updateInOutNotification.action"

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
  "code": 200
}

Valid status codes

200, 403, 414, 416, 500

See Status codes .

Muting members by tag

Mutes members by tag.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room id
operatorstringYesOperator accid, must be owner or administrator
targetTagstringYesTarget tag
needNotifybooleanNotrue/false, whether to send notification about muting, the default is true
notifyExtstringNoMute notification extension field
muteDurationintYesMute duration, in seconds, 30 days in maximum, if set to 0, then the mute is cancelled
notifyTargetTagsstringNoTarget tag expression of mute notification, if it is missing, the notification will be sent to the person who has set the targetTag

curl request example

curlcurl -X POST -H 'appkey: fe416640c8e8a72734219e1847ad2547' -H 'cache-control: no-cache' -H 'checksum: 18f5435a7bf287af9150ad608797f75265495034' -H 'content-type: application/x-www-form-urlencoded'  -H 'curtime: 1508481877'  -H 'nonce: 12345' -d 'targetTag=abc&roomid=3001&operator=xxx&muteDuration=123' "https://api.netease.im/nimserver/chatroom/tagTemporaryMute.action"

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
    "code": 200,
    "desc": {
        "muteDuration": 100 //mute duration, if mute is cancelled, then return the remaining duration of the last mute
    }
} 

Valid status codes

200, 403, 414, 416, 500

See Status codes .

Querying the number of online users by tag

Queries the number of online users under by tag. Note that the number of online users is counted as 1 for multiple logins with an account.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room id
tagstringYesTag

curl request example

curlcurl -X POST -H 'appkey: fe416640c8e8a72734219e1847ad2547' -H 'cache-control: no-cache' -H 'checksum: 18f5435a7bf287af9150ad608797f75265495034' -H 'content-type: application/x-www-form-urlencoded'  -H 'curtime: 1508481877'  -H 'nonce: 12345' -d 'tag=abc&roomid=3001' "https://api.netease.im/nimserver/chatroom/tagMembersCount.action"

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
  "data": {
    "tag": "abc",
    "onlineUserCount":222
  },
  "code": 200
}

Valid status codes

200, 403, 414, 416, 500

See Status codes .

Querying online member list by tag

Queries online member list by tag. Note that multiple records will be returned with multi-client login.

Request URL

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

For information about headers in the request, see Overview.

Parameters

ParameterTypeRequiredDescription
roomidlongYesChat room id
tagstringYesTag
endTimelongYesStart time, searched in reverse order, if 0 is passed, then search starts from the current time forward
limitintYesNumber of entries, 100 in maximum

curl request example

curlcurl -X POST -H 'appkey: fe416640c8e8a72734219e1847ad2547' -H 'cache-control: no-cache' -H 'checksum: 18f5435a7bf287af9150ad608797f75265495034' -H 'content-type: application/x-www-form-urlencoded'  -H 'curtime: 1508481877'  -H 'nonce: 12345' -d 'tag=abc&roomid=3001&endTime=0&limit=100' "https://api.netease.im/nimserver/chatroom/tagMembersQuery.action"

Response

The data returned in the HTTP response is in JSON format.

json"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "data": [
      {
        "roomid": 111,
        "accid": "abc",
        "nick": "zlw",
        "avator": "http://nim.nos.netease.com/MTAxMTAwMg==xxx==",
        "ext": "ext",
        "type": "administrator",
        "level": 2,
        "onlineStat": true,
        "joinTime": "1487145487971",
        "Blocklisted": true,
        "muted": true,
        "tempMuted": true,
        "tempMuteTtl": 120,
        "isRobot": true,
        "robotExpirAt": 120,
        "tags": "aaa",
        "notifyTargetTags": "{\"tag\": \"abc\"} and {\"tag\": \"def\"}"
      }
    ]
  },
  "code": 200
}

Valid status codes

200, 403, 414, 416, 500

See Status codes .

Was this page helpful?
Yes
No
  • Creating a chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Querying the chat room profile
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Query chat room profiles
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Updating chat room information
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Changing the on/off status
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Setting user roles in the chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Requesting the URL address of a chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Sending messages
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Adding a chatbot to the chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Deleting a chatbot from the chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Deleting chatbots
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Setting temporary mute status
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Muting all members in the chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Querying TOP N indicators in a chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Getting a paginated list of members
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Response
  • Get mutiple online member profiles at a time
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Changing user profiles in a chat room
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Querying the list of chat rooms created by users
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Turning off notifications for joining or leaving specified chat rooms
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Muting members by tag
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Querying the number of online users by tag
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Querying online member list by tag
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes