Skip to main content

Check friendship

Check the friendship status between a user and one or more target users.

Request method

POST: https://Base URL/v4/friend/relationship/get

Rate limit: 100 requests per second (rate limit counts each user in the batch individually; checking 10 users counts as 10 requests)

Signature required: All server API requests require signature verification. See API request signature.

Request body

The request body is in application/json format and supports the following parameters:

ParameterTypeRequiredDescription
userIdStringYesThe user ID performing the check.
targetIdsString[]YesTarget user IDs to check. Maximum 20 per request.

Request example

HTTP
POST /v4/friend/relationship/get HTTP/1.1
Host: api.sg-light-api.com
App-Key: uwd1c0sxdlx2
Nonce: 14314
Timestamp: 1408710653491
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Content-Type: application/json

{
"userId": "id1",
"targetIds": ["id2", "id3", "id4"]
}

Response

FieldTypeDescription
codeNumberStatus code. 0 indicates success.
result.friendshipsObject[]Friendship check results.
result.friendships[i].userIdStringTarget user ID.
result.friendships[i].resultNumberFriendship status: 1 = neither user is the other's friend. 4 = both users are mutual friends.

Response example

HTTP
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"code": 0,
"result": {
"friendships": [
{
"userId": "id2",
"result": 1
},
{
"userId": "id3",
"result": 2
},
{
"userId": "id4",
"result": 3
}
]
}
}