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.

(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. AppIDs which are known not to contain this field: 215, 17550, 17700, and 240 when protocol = 7.

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 payloads of the received packets, then pass that into a function like BZ2_bzBuffToBuffDecompress() in C, bzdecompress() in PHP, or bz2.decompress() in Python. Compression appears to have been phased out in newer Source games, but is still present in ~2006-era engines.

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:

A2S_INFO

Basic information about the server.

A2S_PLAYER

Details about each player on the server.

A2S_RULES

The rules the server is using.

A2A_PING

Ping the server. (DEPRECATED)

A2S_SERVERQUERY_GETCHALLENGE

Returns a challenge number for use in the player and rules query. (DEPRECATED)

Queries should be sent in UDP packets to the listen port of the server.

A2S_INFO

Retrieves information about the server including, but not limited to: its name, the map currently being played, and the number of players.

Note:When a player is trying to connect to a server, they are recorded in the number of players. However, they will not be in the list of player information chunks.

Warning: CS:GO Server by default returns only max players and server uptime. You have to change server cvar "host_players_show" in server.cfg to value "2" if you want to revert to old format with players list.

Warning: Some servers will bypass replying with a challenge, and instead will immediately send a full rules response. This has been observed in a few servers that have modified their network code and in servers running older engines. A simple way to detect this situation is if the packet header is -2 (0xFFFFFFFE), or -1 (0xFFFFFFFF) with a message header of 0x45 ('E').

Warning: CS:GO Rules reply is broken since update CSGO 1.32.3.0 (Feb 21, 2014). Before the update rules got truncated when exceeding MTU, after the update rules reply is not sent at all. You can also see a console message: [NET] Cannot send connectionless packet to xxx.xxx.xxx.xxx:xxxxx '0x45' exceeding MTU (2644)

A2S_SERVERQUERY_GETCHALLENGE

A2S_PLAYER and A2S_RULES queries both require a challenge number. Formerly, this number could be obtained via an A2S_SERVERQUERY_GETCHALLENGE request. In newer games it no longer works. Instead, issue A2S_PLAYER or A2S_RULES queries with an initial challenge of -1 (0xFFFFFFFF) to receive a usable challenge number.

On some engines (confirmed AppIDs: 17510, 17530, 17740, 17550, 17700) it can be used. The format is: