- Documentation
- Server APIs v2
- API testing
- API testing with Postman
API testing with Postman
This document describes how to use the Postman tool for Server API testing.
Postman is an API testing tool, which makes it easy to ensure your APIs are reliable and ready to launch.
For your convenience, ZEGO provides the Postman Collection and predefines request parameters for each API. When the Collection is imported, you can start testing the RTC Server APIs after changing the parameter values.
1 Prerequistes
- Download Postman.
- Download and extract the RTC Postman Collection package.
- Log in to the ZEGO Admin Console and obtain the AppId and ServerSecret.
The UI of Postman varies on different platforms. This document uses Postman on macOS as an example.
2 Import and configure the Postman Collection
- Click the Import button, and upload the extracted two Postman Collection files.
- Select RTC in the drop-down box to set the environment.
- Select Environments > RTC, in the CURRENT VALUE column, fill in the AppID and ServerSecret you get in the previous step, and click Save.
If the AppID uses the testing environment (for details, see the description of the IsTest
parameter in Accessing Server APIs - Public parameters), you need to change the IsTest
value (the last parameter in the figure above) to true
.
4 API testing
The following 3 APIs are used as examples to describe how to use Postman for API testing.
The Postman Collection provided by ZEGO automatically fills in public parameters with environment variables and pre-scripts. You can see the pre-script in the location shown below and use it as a reference when developing the server API.
4.1 Send a broadcast message
This API is used for sending broadcast messages in a room.
You need to log in to a room before making the API call.
You can refer to the Quick start to build your own app and log in to a room.
- Select Collections > SendBroadcastMessage, refer to the Send a broadcast message to modify the parameters accordingly.
Parameter values wrapped in double curly braces are environment variables and do not need to be modified.
- Click Send, and check the returned message. If the returned error code is not
0
, then modify your request and send it again.
4.2 Kick a user out of a room
This API is used for kicking one or more specified users out of a room, and all the streaming operations of the target user will stop.
You need to log in to a room before making the API call.
You can refer to the Quick start to build your own app and log in to a room.
- Select Collections > KickoutUser, refer to the Kick a user out of a room to modify the parameter values accordingly.
UserId[]
is the ID of the target user that you want to kick out. You can kick out of 1-5 users at a time, for more, check the description of this parameter.
- Click Send, and check the returned message. If the returned error code is not
0
, then modify your request and send it again.
4.3 Start stream mixing
This API is used for starting or updating a stream mixing task.
Before using this interface for the first time, you need to contact ZEGO technical support to activate it.
- Select Collections > StartMix, and refer to the Start stream mixing to modify the
Body
parameters accordingly.
- Click Send, and check the returned message. If the returned error code is not
0
, then modify your request and send it again.