Instant Messaging
Server
Getting Started
Limits
Platform Service
Webhooks
Overview
Message-related Callback
Related Callbacks of User Information
Related Callbacks of Advanced Team
Related Callbacks of Super Team
Related Callbacks of Audio and Video
Callback related to Log in
Data Sync
Data Sync Overview
Activate Data Sync
IM Session Message Delivery
Other IM Message Delivery
Audio/video/whiteboard Duration Message Delivery
Content Moderation
Overview
Best Practice
API Reference
Overview
Status Code
Account Management
Register Accounts
Refresh Token
Ban Accounts
Mute Accounts
Push Notification
Login Authentication
Messaging
Send Messages
Unsend Messages
Send Broadcast Messages
Upload Files
Delete a message
Delete a roaming message
Message history
History
Custom system notification
User Profile
User Relationship
Host User Relationship
Group
Advanced group
Supergroup
Chat room
Create a chat room
Get the URL of a chat room
Update chat room info
Edit chat room states
Set a timer to close a chat room
Manage roles
Get the member list
Manage chatbots
Manage tags
Message queues
Online Status

Host User Relationship

Update time: 2022/11/25 16:12:14

Add a friend

Adds a friend.

Request URL

POST https://api-sg.netease.im/nimserver/friend/add.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
accidStringYesaccid of friend request initiator
faccidStringYesaccid of friend request recipient
typeintYes1 Add friend , 2 Request to add friend, 3 Agree to add friend, 4 Refuse to add friend
msgStringNoRequest message corresponding to adding a friend, to be assembled by third party with up to 256 characters
serverexStringNoServer-side extension field, with a length limited to 256
This field is read-only on the client side, read-written on the server side

curl request example

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&faccid=lisi&type=1' 'https://api-sg.netease.im/nimserver/friend/add.action'

Response

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

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

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Updating the friend profile

Updates the friend profile, such as alias. You must be a friend of the peer.

Request URL

POST https://api-sg.netease.im/nimserver/friend/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

Parameter Type Required Description
accid String Yes Initiator accid
faccid String Yes Modify friend accid
alias String No Add a alias to friend, with a length limit of 128. You can set to an empty string
ex String No Modify an ex field, with a length limit of 256. You can set to an empty string
serverex String No Modify a serverex field, with a length limit of 256. You can set to an empty string
this field is read-only on the client side, read-written on the server side

curl request example

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&faccid=lisi&alias=lisi' 'https://api-sg.netease.im/nimserver/friend/update.action'

Response

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

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

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Removing a friend

Removes a friend.

Request URL

POST https://api-sg.netease.im/nimserver/friend/delete.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
accidStringYesInitiator accid
faccidStringYesAccid of a friend to be deleted
isDeleteAliasBooleanNoNotes information for whether deletion is required
false: not required (default), true: required

curl request example

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&faccid=lisi' 'https://api-sg.netease.im/nimserver/friend/delete.action'

Response

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

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

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Getting the friendship chain

Queries bilateral friendship from a certain point of time to date.

Request URL

POST https://api-sg.netease.im/nimserver/friend/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
accidStringYesInitiator accid
updatetimeLongYesUpdate timestamp, friends list will be updated upon return of new timestamp by interface
createtimeLongNo[Deprecated] definition is the same as that of updatetime

curl request example

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&createtime=1443599631111' 'https://api-sg.netease.im/nimserver/friend/get.action'

Response

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

"Content-Type": "application/json; charset=utf-8"
{
    "code":200,
    "size":2,
    "friends":
    [
      {"createtime":1440037706987,"bidirection":true,"faccid":"t2"},
      {"createtime":1440037718190,"bidirection":true,"faccid":"t3","alias":"t3"}
    ]
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


Adding a friend to a blocklist or muting a friend

Blocks or unblocks a friend. Mute or unmute a friend.

Request URL

POST https://api-sg.netease.im/nimserver/user/setSpecialRelation.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
accidStringYesUser account, with a maximum length of 32 characters, must be unique
Unique with the APP
targetAccStringYesAccounts that have been blocklisted or muted
relationTypeintYesRelationship type of the operation, 1: blocklist, 2: mute list
valueintYesOperation value, 0: cancel blocklist or mute, 1: add to blocklist or mute list

curl request example

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan&targetAcc=lisi&relationType=1&value=0' 'https://api-sg.netease.im/nimserver/user/setSpecialRelation.action'

Response

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

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

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .


View the blocklist and mute list of specified user

Views the blocklist and mute list of users.

Request URL

POST https://api-sg.netease.im/nimserver/user/listBlackAndMuteList.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
accidStringYesUser account, with a maximum length of 32 characters, must be unique
Unique with the APP

curl request example

curl -X POST -H "AppKey: go9dnk49bkd9jd9vmel1kglw0803mgq3" -H "Nonce: 4tgggergigwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api-sg.netease.im/nimserver/user/listBlackAndMuteList.action'

Response

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

"Content-Type": "application/json; charset=utf-8"
{
  "mutelist": [//List of muted accounts
    "abc",
    "cde"
  ],
  "Blocklist": [//list of blocklisted accounts
    "abc"
  ],
  "code": 200
}

Valid status codes

200, 403, 414, 416, 431, 500

See Status codes .

Was this topic helpful?
Yes
No
  • Add a friend
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Updating the friend profile
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Removing a friend
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Getting the friendship chain
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • Adding a friend to a blocklist or muting a friend
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes
  • View the blocklist and mute list of specified user
  • Request URL
  • Parameters
  • curl request example
  • Response
  • Valid status codes