logo
In-app Chat
ZIMAudio
On this page

CheckFriendsRelation

POST

https://zim-api.zego.im/

By calling this API, you can batch check the friend relationship between one user and up to 20 other users. If you need to increase the limit (up to 50), please contact ZEGOCLOUD Technical Support.

ZEGOCLOUD supports one-sided or two-sided checking of friend relationships. Taking checking the friend relationship between user A and target user B as an example:

  • One-way check: Only check whether user A's friend list has user B.
  • Two-way check: Check whether user A and user B have each other in their friend lists.

The results of checking friend relationships may include:

Check TypeRelationDescription
A's friend list has BB's friend list has A
One-way1Cannot confirm
2✔️Cannot confirm
Two-way3
4✔️
5✔️
6✔️✔️
Note

The users corresponding to the parameters FromUserId and UserId have logged in to the ZIM service by calling the login method on the client, or have completed registration by calling the server-side API.

Note
QPS Limit: 20 times/s

Request

Query Parameters

    Action stringrequired

    Possible values: [CheckFriendsRelation]

    API prototype parameter

    https://zim-api.zego.im/?Action=CheckFriendsRelation

    AppId uint32required

    💡Public parameter. Application ID, assigned by ZEGOCLOUD. Get it from the ZEGOCLOUD Admin Console.

    SignatureNonce stringrequired

    💡Public parameter. A 16-character hexadecimal random string (hex encoding of 8-byte random number). Refer to Signature example for how to generate.

    Timestamp int64required

    💡Public parameter. Current Unix timestamp, in seconds. Refer to Signature example for how to generate, with a maximum error of 10 minutes.

    SignatureVersion stringrequired

    Possible values: [2.0]

    Default value: 2.0

    💡Public parameter. Signature version number.

    Signature stringrequired

    💡Public parameter. Signature, used to verify the legitimacy of the request. Refer to Signing the requests for how to generate an API request signature.

Body

required
    FromUserId stringrequired

    Possible values: <= 32 characters

    Query friend relationships for this UserId.

    UserIds string[]required

    Possible values: <= 20

    List of target users to check friend relationships. Default maximum is 20.

    CheckType numberrequired

    Possible values: [0, 1]

    Check type:

    • 0: Two-way check.
    • 1: One-way check.

Responses

OK
Schema
    Code number

    Return code.

    The following only lists the Code and SubCode related to the API business logic. For complete return codes, please refer to Global Return Codes.

    Note

    When you initiate a request to check the friend relationship between FromUserId and multiple users at the same time:

    • If the friend relationship between FromUserId and 1 or more users is successfully checked, Code will return 0. In this case, please refer to the specific information in Fails to confirm the operation result.
    • If the friend relationship check between FromUserId and all target users fails, Code will return the relevant return code. For details, please refer to Global Return Codes.
    Code / SubCodeDescriptionSuggested Solution
    660000001General business error.Please retry or contact ZEGOCLOUD Technical Support.
    660000002Input parameter error。Please check the input parameters。
    660300005The API call frequency exceeds the AppID-level limit.Please try again later.
    Message string

    Description of the request result.

    RequestId string

    Request ID.

    Successes object[]
    Check success list.
  • Array[
  • UserId string

    Successfully checked the friend relationship between FromUserId and this user ID.

    Relation number

    Relationship type. For details, please refer to the function description of this API.

  • ]
  • Fails object[]
    Check failure list.
    • Code is 0:
    • Fails is empty, indicating that the friend relationship between FromUserId and all target users is successfully checked.
    • Fails is not empty, indicating that the friend relationship check between FromUserId and some target users failed. Please refer to SubCode for processing.
    • Code is not 0:
    • Fails is empty, indicating parameter error, API frequency limit, or system error.
    • Fails is not empty, indicating that the friend relationship check between FromUserId and all target users failed.
  • Array[
  • UserId string

    Failed to check the friend relationship between FromUserId and this user ID.

    SubCode number

    Specific failure return code. For complete return codes, please refer to the Code description or Global Return Codes.

    Relation number

    Relationship type. This field has a value only when the request parameter CheckType is 0, which is 1 or 2. For details of related values, please refer to the function description of this API.

  • ]

Previous

Query the friend list

Next

Change the alias of a friend

On this page

Back to top