API to get the number of servers currently running?

Simply, is there an API to return the number of servers currently running in a game?

Obviously I can use MessagingService to achieve this, I’m just curious to know if there’s a quicker way.

5 Likes

The only API I can find is to get a maximum of 100 running servers for a Place of a game. (Even though the documentation describes it for a game, but asks for a PlaceId?)

Send a GET request to this URL (or just paste it into your browser URL bar):
https://games.roblox.com/v1/games/PLACE_ID_HERE/servers/SERVER_TYPE_HERE?sortOrder=Asc&limit=100

Where SERVER_TYPE_HERE can be Public, Friend, or VIP. See the documentation for more info.

4 Likes

I forgot to mention, I can’t use HTTP Service either as this is for HD Admin. :derp:

Thanks for the response though, this is perfect for almost all other cases!

In that case I would say the best course of action would be to set up a system using MessagingService as to the best of my knowledge I don’t believe there’s any such API for getting the amount of people in a game, from in-game.

1 Like

Maybe this can help? Is there a function for getting a list of servers in your game? [closed] - Scripting Helpers

As @ForeverHD mentioned, he will use this feature for his admin, messaging service is not enabled for all users on Roblox, so the game owner would have to join the beta program(not open to users not on the forum) just to use this feature, which I guess wouldn’t be feasible at the moment.

3 Likes

There isn’t. You can’t get this information without using an endpoint or having the place’s owner set up a MessagingService network. A MessagingService network, however, is a bad idea because that consumes the budget developers have to work with for other purposes and without a dedicated server, things will get undoubtedly messy. Each server needs to send out a message and then collect another incoming message. That’d be heavy.

I would have to disagree with this being intensive at all. All you have to do is setup an event beforehand (e.g. with the topic of “GetAmountOfServers”), generate a unique-id from the original server, setup another event using the unique-id as the topic, fire off to all servers using “GetAmountOfServers”, making sure to attack the unique-id, then have the receiving servers fire back using the unique-id as the topic. During this process, increment a value at the origin for every server which responds, and after 1/2 a second disconnect the event.

I do agree with you and @wevetments for the reasons mentioned, but for now MessagingService appears to be the most effective way without using HTTP Service.

You do have to be mindful of the limitations of MessagingService. I don’t think you would hit it but someone who uses a lot of MessagingService may run into conflictions with your own network.

I don’t necessarily think it’d be intensive but you do have to work with the other developers in mind and their game systems. This and the availability for other users to use this service. Keep in mind that for every place in the game, it will have to send a message when a server list is requested (could be fairly often) to every other server, which then has to send a message back to the requesting server with the JobId and such included on the message.

I see it as fairly taxing. It may not be though.

1 Like

Agree with you there. Fortunately I’ll only be using this for a ‘vote’ command which would be used once or twice a minute at most. Even if the developer was firing off a message every 1/2 second themself, we’d still be in a safe margin of exceeding the limitations.

1 Like

You may use new messaging service for instant updates but you should subscribe just one message for entire HD admin.

1 Like