# How do I get the number of online players in a Minecraft server from outside the client?

I know that the Minecraft client can query the server for number of players and maximum players, even when the server properties has enable-query set to false, but how do I do this outside of the client? I am trying to implement this as part of a mobile (Android) app.

This is actually quite well-detailed at this page. Please note that I am going to detail the common protocol introduced in version 1.7. Additionally, a new protocol was introduced in 1.9pre4 that contains additional information not found in the previous protocol. Let me detail how to get the basic server information in 1.7+:

1. Send a "handshake" packet with the layout:

• 0x00 (Packet ID)
• 0x04 (Protocol Version)
• Length of server address. This is a VarInt, which means that it has a variable length. The last bit of each byte that would normally indicate the sign instead indicates if the next byte is part of the VarInt.
• Server port (as a Short, Big-endian)
• 0x01 (Next State)
2. Send a blank "Status Request" packet with the layout:

• 0x00 (Packet ID)
3. Reading the response, you will get a JSON-encoded object with the following format:

• Version
1. Name
2. Protocol
• Players
1. Max
2. Online
3. Sample
• Description
1. Text
• Favicon
1. Mime-type;encoding,

Since you are writing this for Android, I presume you are using Java. Luckily for you, there is already an open-source Java project that details these steps already made for you. Even better, it shows proper use of VarInt when formatting your packets.