Server queries

As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.
The person who added this notice will be listed in its edit history should you wish to contact them.
You can query information from a running game server using UDP/IP packets. This document describes the packet formats and protocol to access this data.
Data Types
All server queries consist of five basic types of data packed together into a data stream. All types are little endian, which is the default on most languages on x86 CPUs. Java users should use ByteBuffer to convert.
Name | Description |
---|---|
byte | 8 bit character or unsigned integer |
short | 16 bit signed integer |
long | 32 bit signed integer |
float | 32 bit floating point |
long long | 64 bit unsigned integer |
string | variable-length byte field, encoded in UTF-8, terminated by 0x00 |
Protocol
Steam uses a packet size of 1400 bytes + IP/UDP headers. If a request or response needs more packets for the data it starts the packets with an additional header.
Simple Response
Data | Type | Comment |
---|---|---|
Header | long | Always equal to -1 (0xFFFFFFFF). Means it isn't split. |
Payload |
Multi-packet Response
Goldsource Server
Data | Type | Comment |
---|---|---|
Header | long | Always equal to -2 (0xFFFFFFFE). Means the packet is split. |
ID | long | Unique number assigned by server per answer. |
Packet number | byte | Upper 4 bits represent the number of the current packet (starting at 0) and bottom 4 bits represent the total number of packets (2 to 15). |
Payload |
Source Server
Data | Type | Comment | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Header | long | Always equal to -2 (0xFFFFFFFE). Means the packet is split. | |||||||||
ID | long | Same as the Goldsource server meaning. However, if the ![]() | |||||||||
Total | byte | The total number of packets in the response. | |||||||||
Number | byte | The number of the packet. Starts at 0. | |||||||||
Size | short | (Orange Box Engine and above only.) Maximum size of packet before packet switching occurs. The default value is 1248 bytes (0x04E0), but the server administrator can decrease this. For older engine versions: the maximum and minimum size of the packet was unchangeable. | |||||||||
This is only present in the first packet of the response and only if the response is being compressed.
To uncompress this response: collect and assemble all the packets of the answer, then pass that into a function like BZ2_bzBuffToBuffDecompress() in C, bzdecompress() in PHP, or bz2.decompress() in Python. | |||||||||||
Payload |
Because UDP packets can arrive in different order or delayed, every packet should be verified by its "ID" and "Number"! Every request or response with or without this header is continued with an integer -1 (0xFFFFFFFF) and the user data. So by reading the first 4 bytes you can decide whether the data is split (-2) or in one packet (-1).

Requests
The server responds to 5 queries:
A2A_PING
- Ping the server.
A2S_SERVERQUERY_GETCHALLENGE
- Returns a challenge number for use in the player and rules query.
A2S_INFO
- Basic information about the server.
A2S_PLAYER
- Details about each player on the server.
A2S_RULES
- The rules the server is using.
Queries should be sent in UDP packets to the listen port of the server.
A2A_PING
Ping the server to see if it exists, this can be used to calculate the latency to the server.

Request format
Data | Type | Value |
---|---|---|
Header | byte | 'i' (0x69) |
FF FF FF FF 69 ÿÿÿÿi |
Response format
Goldsource Server
Data | Type | Value |
---|---|---|
Header | byte | 'j' (0x6A) |
Payload | string | Null |
FF FF FF FF 6A 00 ÿÿÿÿj. |
Source Server
Data | Type | Value |
---|---|---|
Heading | byte | 'j' (0x6A) |
Payload | string | '00000000000000' |
FF FF FF FF 6A 30 30 30 30 30 30 30 30 30 30 30 ÿÿÿÿj00000000000 30 30 30 00 000. |
A2S_INFO
Retrieves information about the server including, but not limited to: its name, the map currently being played, and the number of players.
Request format
Data | Type | Value |
---|---|---|
Header | byte | 'T' (0x54) |
Payload | string | "Source Engine Query" |
FF FF FF FF 54 53 6F 75 72 63 65 20 45 6E 67 69 ÿÿÿÿTSource Engi 6E 65 20 51 75 65 72 79 00 ne Query |
Response format
Goldsource servers

Data | Type | Comment | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Header | byte | Always equal to 'm' (0x6D.) | ||||||||||||||||||||||||
Address | string | IP address and port of the server. | ||||||||||||||||||||||||
Name | string | Name of the server. | ||||||||||||||||||||||||
Map | string | Current map the server has loaded. | ||||||||||||||||||||||||
Folder | string | Name of the folder containing the game files. | ||||||||||||||||||||||||
Game | string | Full name of the game. | ||||||||||||||||||||||||
Players | byte | Number of players on the server. | ||||||||||||||||||||||||
Max. Players | byte | Maximum number of players the server reports it can hold. | ||||||||||||||||||||||||
Protocol | byte | Protocol version used by the server. | ||||||||||||||||||||||||
Server type | byte | Indicates the type of server:
| ||||||||||||||||||||||||
Environment | byte | Indicates the operating system of the server:
| ||||||||||||||||||||||||
Visibility | byte | Indicates whether the server requires a password:
| ||||||||||||||||||||||||
Mod | byte | Indicates whether the game is a mod: | ||||||||||||||||||||||||
These fields are only present in the response if "Mod" is 1:
| ||||||||||||||||||||||||||
VAC | byte | Specifies whether the server uses VAC:
| ||||||||||||||||||||||||
Bots | byte | Number of bots on the server. |

A2S_SERVERQUERY_GETCHALLENGE
Request format
Challenge values are required for A2S_PLAYER
and A2S_RULES
requests, you can use this request to get one.

A2S_PLAYER
and A2S_RULES
queries with a challenge value of -1 (0xFF FF FF FF)
and they will respond with a challenge value to use (using the response format below).
FF FF FF FF 57
Response format
Data | Type | Comment |
---|---|---|
Type | byte | Should be equal to 'A' (0x41) |
Challenge | long | The challenge number to use |
Example response:
FF FF FF FF 41 32 42 59 45
A2S_PLAYER
Request format
FF FF FF FF 55 <4 byte challenge number>
The challenge number can either be set to -1 (0xFF FF FF FF)
to have the server response with S2C_CHALLENGE
, or use the value from a previous A2S_SERVERQUERY_GETCHALLENGE
request.
Response format
The players response has two sections, the initial header:
Data | Type | Comment |
---|---|---|
Type | byte | Should be equal to 'D' (0x44) |
Num Players | byte | The number of players reported in this response |
Then for each player the following fields are sent:
Data | Type | Comment |
---|---|---|
Index | byte | The index into [0.. Num Players] for this entry |
Player Name | string | Player's name |
Kills | long | Number of kills this player has |
Time connected | float | The time in seconds this player has been connected |


A2S_RULES
Request format
FF FF FF FF 56 <4 byte challenge number>
The challenge number can either be set to -1 (0xFF FF FF FF)
to have the server reply with S2C_CHALLENGE
, or use the value from a previous A2S_SERVERQUERY_GETCHALLENGE
request.
Response format
The rules response has two sections, the initial header:
Data | Type | Comment |
---|---|---|
Type | byte | Should be equal to 'E' (0x45) |
Num Rules | short | The number of rules reported in this response |
Then for each rule the following fields are sent:
Data | Type | Comment |
---|---|---|
Rule Name | string | The name of the rule |
Rule Value | string | The rule's value |
Implementations
- Source Server Query Library C library
- GameServer Java library
- QueryEd Java library
- Steam Condenser Java, PHP, and Ruby library
- Net-SRCDS-Queries Perl module
- SRCDSpy Python library
- SourceLib Python library
- aQuery VB.NET library
- SourceStats Source Server Statistics
- PHP Source Query PHP library