Admin Endpoints

Detailed documentation on how to use our API endpoints effectively.

1. Test if server is running

Calling this api will return Pong!.

GET
https://test.socketlink.io/api/v1/ping

Response

200 Response
Pong!

2. Fetch usage metrics

You can fetch the latest usage metrics of the allocated resources.

GET
https://test.socketlink.io/api/v1/metrics

Headers
api-key: $ADMIN_API_KEY

Response

200 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.

GET
https://test.socketlink.io/api/v1/mysql/sync

Headers
api-key: $ADMIN_API_KEY

Response

200 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.

GET
https://test.socketlink.io/api/v1/rooms/users/all

Headers
api-key: $ADMIN_API_KEY

Response

200 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.

POST
https://test.socketlink.io/api/v1/rooms/users

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
{
  "rid": [
    "pub-state-cache-test-0",
    "pub-state-cache-test-3"
  ]
}
  • rid : Room ID for which you want to fetch the users.

Response

200 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.

POST
https://test.socketlink.io/api/v1/broadcast

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
{
  "message": "hello friends!"
}
  • message : Insert the message that you want to send to everyone on the server.

Response

200 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.

POST
https://test.socketlink.io/api/v1/rooms/broadcast

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
{
  "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

200 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.

POST
https://test.socketlink.io/api/v1/connections/broadcast

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
{
  "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

200 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.

POST
https://test.socketlink.io/api/v1/rooms/users/ban

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
[
  {
    "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

200 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.

POST
https://test.socketlink.io/api/v1/rooms/users/unban

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
[
  {
    "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

200 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.

GET
https://test.socketlink.io/api/v1/server/messaging/enable

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY

Response

200 Response
{
  "message": "Messaging successfully enabled for everyone!"
}

12. Disable messaging for everyone

This will disable the messaging for everyone on the server.

GET
https://test.socketlink.io/api/v1/server/messaging/disable

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY

Response

200 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.

POST
https://test.socketlink.io/api/v1/rooms/messaging/disable

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
[
  {
    "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

200 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.

POST
https://test.socketlink.io/api/v1/rooms/messaging/enable

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY
Body
[
  {
    "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 disabled
  • uid : Insert all the uids that you want to allow sending messages to the corresponding rid, where it was previously disabled

Response

200 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.

GET
https://test.socketlink.io/api/v1/users/banned

Headers
Content-Type: application/json
api-key: $ADMIN_API_KEY

Response

200 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.

GET
https://test.socketlink.io/api/v1/messages/room

Headers
api-key: $ADMIN_API_KEY
Path Parameters
rid
  • rid : Replace the rid with the one you are connected to.
Query Parameters
limit: 10
offset: 0
  • limit : Max number of latest messages you want to fetch, can't be more than 10
  • uid : Use the offset if you want to fetch more previous messages.

Response

200 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.

DEL
https://test.socketlink.io/api/v1/database

Headers
api-key: $ADMIN_API_KEY

Response

200 Response
{
  "message": "Database truncated successfully!"
}