Skip to main content
Version: 1.3.0

Kafka

Binary Layout

FieldInternal NameDescriptionType / FormatExample / Values
SizelengthTotal size of the request (excluding this field)int32e.g. 0x0000012C
API Keyapi_keyIdentifies the type of requestint160 = Produce, 1 = Fetch, etc.
API Versionapi_versionVersion of the API being usedint16e.g. 7
Correlation IDcorrelation_idUsed to match requests to responsesint32e.g. 12345
Client IDclient_idOptional identifier of the clientstring (nullable)e.g. "my-client"
Request Body(varies by API)The actual request payloadStructured binaryDepends on api_key and api_version

Common API Keys

API KeyNamePurpose
0ProduceSend messages to a topic
1FetchRetrieve messages from a topic
3MetadataGet topic/partition info
8OffsetGet earliest/latest offsets
18ApiVersionsDiscover supported API versions
21SaslHandshakeSASL authentication handshake
22SaslAuthenticateSASL authentication
42DescribeClusterGet cluster metadata

Primitive Types Used

TypeDescription
int8/16/32/64Signed integers (big-endian)
stringLength-prefixed UTF-8 string
array<T>Length-prefixed array of type T
bytesLength-prefixed byte array
varintVariable-length integer (zigzag encoding)

Response Structure

FieldDescription
correlation_idMatches the request
response_bodyDepends on the request type