Admin Endpoints
Detailed documentation on how to use our API endpoints effectively.
1. Test if server is running
Calling this api will return Pong!
.
GEThttps://test.socketlink.io/api/v1/ping
Response
Pong!
2. Fetch usage metrics
You can fetch the latest usage metrics of the allocated resources.
GEThttps://test.socketlink.io/api/v1/metrics
api-key: $ADMIN_API_KEY
Response
{ "connections": 0, "messages_sent": 0, "average_payload_size": 0, "total_payload_sent": 1848562260, "total_rejected_requests": 16, "average_latency": 0, "dropped_messages": 0, "total_failed_api_calls": 62, "total_success_api_calls": 1249, "total_failed_connection_attempts": 0, "total_mysql_db_batch_writes": 0, "total_local_db_writes": 0, "total_success_webhook_calls": 0, "total_failed_webhook_calls": 0 }
3. Sync MySQL buffers
You can sync all the data stored in the server buffers to integrated MySQL server.
GEThttps://test.socketlink.io/api/v1/mysql/sync
api-key: $ADMIN_API_KEY
Response
{ "message": "MySQL data synced successfully!" }
4. Fetch all the rooms and their users
This will give all the rooms that are present and all the users present in each of the rooms.
GEThttps://test.socketlink.io/api/v1/rooms/users/all
api-key: $ADMIN_API_KEY
Response
[ { "rid": "pub-state-cache-test-0", "uid": [ "c901c777-31ff-4e5c-afb2-f67d9bf75059", "cf38a9e4-d873-43a2-8bef-b9c40c8284f2" ] } ]
5. Fetch all the users for the given rooms
This will fetch all the users present in the given rooms.
POSThttps://test.socketlink.io/api/v1/rooms/users
Content-Type: application/json
api-key: $ADMIN_API_KEY
{
"rid": [
"pub-state-cache-test-0",
"pub-state-cache-test-3"
]
}
rid :
Room ID for which you want to fetch the users.
Response
[ { "rid": "pub-state-cache-test-0", "uid": [ "c901c777-31ff-4e5c-afb2-f67d9bf75059", "cf38a9e4-d873-43a2-8bef-b9c40c8284f2" ] }, { "rid": "pub-state-cache-test-3", "uid": [] } ]
6. Send a message to everyone connected on the server
This will send the given message to everyone connected to the server.
POSThttps://test.socketlink.io/api/v1/broadcast
Content-Type: application/json
api-key: $ADMIN_API_KEY
{
"message": "hello friends!"
}
message :
Insert the message that you want to send to everyone on the server.
Response
{ "message": "Successfully broadcasted the message to everyone on the server!" }
7. Send a message to everyone connected in a room
This will send message to all the users of the room.
POSThttps://test.socketlink.io/api/v1/rooms/broadcast
Content-Type: application/json
api-key: $ADMIN_API_KEY
{
"rid": [
"pub-state-cache-test-3",
"pub-state-cache-test-2"
],
"message": "this is for 3 and 2"
}
rid :
Insert all the rids you want to send the message to.message :
Insert the message that you want to send to the given rooms.
Response
{ "message": "Successfully broadcasted the message to the given rooms!" }
8. Send a message to a particular connection
This will send message to given users.
POSThttps://test.socketlink.io/api/v1/connections/broadcast
Content-Type: application/json
api-key: $ADMIN_API_KEY
{
"uid": [
"test",
"test2"
],
"message": "this is for test and test2"
}
uid :
Insert all the uids you want to send the message to.message :
Insert the message that you want to send to the given connections.
Response
{ "message": "Successfully broadcasted the message to the given connections!" }
9. Ban the user globally or in a room
This will ban the user globally or in multiple rooms.
If a user is banned globally, he won't be able to connect to the server until he is unbanned. If the user is banned from some rooms, he will simply be unsubscribed from those rooms with a WebSocket message.
POSThttps://test.socketlink.io/api/v1/rooms/users/ban
Content-Type: application/json
api-key: $ADMIN_API_KEY
[
{
"rid": "global",
"uid": [
"test",
"test2",
"test3"
]
}
]
rid :
Insert the rid where you want to ban the provided uids.uid :
Insert all the uids you want to ban in a given room.
Response
{ "message": "Given users are successfully banned from the given rooms!" }
10. Unban the user globally or in a room
This will unban the user globally or in the provided rooms.
POSThttps://test.socketlink.io/api/v1/rooms/users/unban
Content-Type: application/json
api-key: $ADMIN_API_KEY
[
{
"rid": "global",
"uid": [
"test",
"test2",
"test3"
]
}
]
rid :
Insert the rid where you want to unban the provided uids.uid :
Insert all the uids you want to unban in a given room.
Response
{ "message": "Given users are successfully unbanned from the given rooms!" }
11. Enable messaging for everyone
This will enable the messaging for everyone on the server.
GEThttps://test.socketlink.io/api/v1/server/messaging/enable
Content-Type: application/json
api-key: $ADMIN_API_KEY
Response
{ "message": "Messaging successfully enabled for everyone!" }
12. Disable messaging for everyone
This will disable the messaging for everyone on the server.
GEThttps://test.socketlink.io/api/v1/server/messaging/disable
Content-Type: application/json
api-key: $ADMIN_API_KEY
Response
{ "message": "Messaging successfully disabled for everyone!" }
13. Disable the messaging for selected uids in selected rooms
This will prevent the given users from sending the messages in the given rooms.
POSThttps://test.socketlink.io/api/v1/rooms/messaging/disable
Content-Type: application/json
api-key: $ADMIN_API_KEY
[ { "rid": "global", "uid": [ "test", "test2", "test3" ] }, { "rid": "pub-state-cache-test-2", "uid": [ "test", "test2" ] } ]
rid :
Insert the rid where you want to stop the message sending.uid :
Insert all the uids that you want to prevent sending messages to the corresponding rid.
Response
{ "message": "Messaging successfully disabled for the given users in the given rooms!" }
14. Enable the messaging for selected uids in selected rooms
This will allow the given users from sending the messages in the given rooms.
POSThttps://test.socketlink.io/api/v1/rooms/messaging/enable
Content-Type: application/json
api-key: $ADMIN_API_KEY
[ { "rid": "global", "uid": [ "test", "test2", "test3" ] }, { "rid": "pub-state-cache-test-2", "uid": [ "test", "test2" ] } ]
rid :
Insert the rid where you want to enable the message sending and was previously disableduid :
Insert all the uids that you want to allow sending messages to the corresponding rid, where it was previously disabled
Response
{ "message": "Messaging successfully enabled for the given users in the given rooms!" }
15. Get all the banned users across different rooms on the server
This will return a json object containing all the banned users across different rooms on the server.
GEThttps://test.socketlink.io/api/v1/users/banned
Content-Type: application/json
api-key: $ADMIN_API_KEY
Response
{ "message": "Messaging successfully disabled for the users of the given rooms!" }
16. Fetch the messages for the cache rooms
This will fetch the messages for the cache room which the user is connected to.
GEThttps://test.socketlink.io/api/v1/messages/room
api-key: $ADMIN_API_KEY
rid
rid :
Replace the rid with the one you are connected to.
limit: 10
offset: 0
limit :
Max number of latest messages you want to fetch, can't be more than 10uid :
Use the offset if you want to fetch more previous messages.
Response
{ "message": "Messaging successfully disabled for the users of the given rooms!" }
17. Truncate the cache rooms database
This will delete all the messages from the cache rooms database, It should only be used when all the space is filled up.
DELhttps://test.socketlink.io/api/v1/database
api-key: $ADMIN_API_KEY
Response
{ "message": "Database truncated successfully!" }