Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

Kafka Core Protocol APIs

This document specifies the core Kafka protocol APIs used for message production, consumption, and cluster metadata. These APIs form the foundation of all Kafka client operations.


API KeyNamePurpose
0ProduceSend records to partitions
1FetchRetrieve records from partitions
2ListOffsetsQuery offset by timestamp
3MetadataDiscover cluster topology
18ApiVersionsQuery supported API versions

The Produce API sends record batches to topic partitions. It is the primary API for message production.

VersionKafkaKey Changes
00.8.0Initial version (removed in 4.0)
30.11.0Transactional ID + message format v2 (4.0 baseline)
40.11.0KAFKA_STORAGE_ERROR
51.0.0Log start offset in response
72.1.0Zstandard compression (KIP-110)
82.3.0Record errors + error message (KIP-467)
92.4.0Flexible versions
103.7.0Current leader + node endpoints (KIP-951)
113.8.0TRANSACTION_ABORTABLE (KIP-890)
134.0.0Topic IDs (KIP-516)
ProduceRequest =>
transactional_id: NULLABLE_STRING
acks: INT16
timeout_ms: INT32
topic_data: [TopicData]
TopicData =>
name: STRING
topic_id: UUID
partition_data: [PartitionData]
PartitionData =>
index: INT32
records: RECORDS

Topic names are used through v12; v13+ uses topic_id instead.

FieldTypeDescription
transactional_idNULLABLE_STRINGTransaction ID (null for non-transactional)
acksINT16Required acknowledgments (-1, 0, 1)
timeout_msINT32Request timeout in milliseconds
topic_dataARRAYPer-topic record data
partition_dataARRAYPer-partition record batches
recordsRECORDSRecord batch data
ProduceResponse =>
responses: [TopicResponse]
throttle_time_ms: INT32
node_endpoints: [NodeEndpoint]
TopicResponse =>
name: STRING
topic_id: UUID
partition_responses: [PartitionResponse]
PartitionResponse =>
index: INT32
error_code: INT16
base_offset: INT64
log_append_time_ms: INT64
log_start_offset: INT64
record_errors: [RecordError]
error_message: NULLABLE_STRING
current_leader: LeaderIdAndEpoch
NodeEndpoint =>
node_id: INT32
host: STRING
port: INT32
rack: NULLABLE_STRING
FieldTypeDescription
error_codeINT16Partition-level error
base_offsetINT64Offset of first record in batch
log_append_time_msINT64Timestamp (-1 if CreateTime)
log_start_offsetINT64Log start offset
record_errorsARRAYPer-record errors (v8+)
throttle_time_msINT32Quota throttle time
current_leaderSTRUCTSuggested leader for future requests (v10+)
node_endpointsARRAYEndpoint list for leaders in response (v10+)
acksNameGuaranteeResponse
0Fire-and-forgetNoneNo response sent
1LeaderLeader wrote to local logAfter leader persist
-1AllAll ISR replicas wroteAfter ISR persist
Produce request acknowledgment flow for acks=0, acks=1, and acks=allProducerLeaderFollower 1Follower 2ProducerProducerLeaderLeaderFollower 1Follower 1Follower 2Follower 2acks=0ProduceRequestNo response expectedacks=1ProduceRequestWrite to logProduceResponse(offset)ReplicateReplicateacks=-1 (all)ProduceRequestWrite to logReplicateReplicateAckAckProduceResponse(offset)
AspectGuarantee
OrderingRecords within a batch must be written in batch order
AtomicityBatch to single partition must succeed or fail atomically
DurabilityDepends on acks setting and min.insync.replicas
IdempotenceWith enable.idempotence, duplicates are prevented

acks=0 No Response

With acks=0, the broker must not send a response. The client must not wait for a response. Delivery is not confirmed.

Error CodeRetriableCauseRecovery
NOT_LEADER_OR_FOLLOWERStale leaderRefresh metadata, retry
REQUEST_TIMED_OUTBroker timeoutRetry with backoff
NOT_ENOUGH_REPLICASISR too smallWait, retry
MESSAGE_TOO_LARGERecord exceeds limitReduce message size
TOPIC_AUTHORIZATION_FAILEDNo Write permissionCheck ACLs
OUT_OF_ORDER_SEQUENCE_NUMBERSequence gapFatal for idempotent

The Fetch API retrieves record batches from topic partitions. It supports long-polling, session-based fetching, and transactional isolation.

VersionKafkaKey Changes
00.8.0Initial version (removed in 4.0)
40.11.0Isolation level (4.0 baseline)
51.0.0Log start offset
71.1.0Fetch sessions
92.1.0Current leader epoch (KIP-320)
102.1.0Zstandard support (KIP-110)
112.3.0Rack ID
122.4.0Flexible versions + last fetched epoch
132.8.0Topic IDs (KIP-516)
143.4.0Tiered storage offset moved (KIP-405)
153.5.0Replica state (KIP-903)
163.7.0Node endpoints (KIP-951)
173.8.0Replica directory ID (KIP-853)
184.1.0High-watermark in request (KIP-1166)
FetchRequest =>
cluster_id: NULLABLE_STRING
replica_id: INT32
replica_state: ReplicaState
max_wait_ms: INT32
min_bytes: INT32
max_bytes: INT32
isolation_level: INT8
session_id: INT32
session_epoch: INT32
topics: [TopicRequest]
forgotten_topics_data: [ForgottenTopic]
rack_id: STRING
TopicRequest =>
topic: STRING
topic_id: UUID
partitions: [PartitionRequest]
PartitionRequest =>
partition: INT32
current_leader_epoch: INT32
fetch_offset: INT64
last_fetched_epoch: INT32
log_start_offset: INT64
partition_max_bytes: INT32
replica_directory_id: UUID
high_watermark: INT64
ReplicaState =>
replica_id: INT32
replica_epoch: INT64

Topic names are used through v12; v13+ uses topic_id instead.

FieldTypeDescription
cluster_idNULLABLE_STRINGCluster ID for validation (v12+)
replica_idINT32Replica ID (-1 for consumers, v0-14)
replica_stateSTRUCTReplica ID + epoch (v15+)
max_wait_msINT32Maximum wait time for data
min_bytesINT32Minimum bytes to return
max_bytesINT32Maximum bytes to return
isolation_levelINT80=read_uncommitted, 1=read_committed
session_idINT32Fetch session ID (0 for new)
fetch_offsetINT64Offset to fetch from
last_fetched_epochINT32Last fetched epoch for fencing (v12+)
partition_max_bytesINT32Maximum bytes per partition
forgotten_topics_dataARRAYPartitions to remove from session (v7+)
rack_idSTRINGConsumer rack ID (v11+)
FetchResponse =>
throttle_time_ms: INT32
error_code: INT16
session_id: INT32
responses: [TopicResponse]
node_endpoints: [NodeEndpoint]
TopicResponse =>
topic: STRING
topic_id: UUID
partitions: [PartitionResponse]
PartitionResponse =>
partition: INT32
error_code: INT16
high_watermark: INT64
last_stable_offset: INT64
log_start_offset: INT64
diverging_epoch: EpochEndOffset
current_leader: LeaderIdAndEpoch
snapshot_id: SnapshotId
aborted_transactions: [AbortedTransaction]
preferred_read_replica: INT32
records: RECORDS
EpochEndOffset =>
epoch: INT32
end_offset: INT64
SnapshotId =>
end_offset: INT64
epoch: INT32
FieldTypeDescription
high_watermarkINT64End offset of committed data
last_stable_offsetINT64End of non-transactional or committed data
log_start_offsetINT64Log start offset
aborted_transactionsARRAYAborted transaction markers
preferred_read_replicaINT32Suggested follower for reads
recordsRECORDSFetched record batches
LevelValueBehavior
read_uncommitted0Returns all records up to high watermark
read_committed1Returns only committed records (filters aborted transactions)
Records visible under read_uncommitted and read_committed fetch isolationRecords visible under read_uncommitted and read_committed fetch isolationLog (partition)Consumer ViewsCommittedRecordsUncommittedTransactionFutureread_uncommitted:Sees C + Uread_committed:Sees C onlylast_stable_offset marksboundary of committed data

The Fetch API supports long polling via min_bytes and max_wait_ms:

Fetch long polling with min_bytes and max_wait_msConsumerBrokerConsumerConsumerBrokerBrokerFetchRequest(min_bytes=1, max_wait_ms=500)alt[Data available immediately]FetchResponse(records)[No data, wait]Wait up to max_wait_msalt[Data arrives]FetchResponse(records)[Timeout]FetchResponse(empty)
AspectGuarantee
OrderingRecords returned in offset order per partition
CompletenessAll records in requested range (up to size limits)
IsolationWith read_committed, no uncommitted transactional records
FreshnessMay return slightly stale data after leader change
Error CodeRetriableCauseRecovery
OFFSET_OUT_OF_RANGEInvalid fetch offsetReset to valid offset
NOT_LEADER_OR_FOLLOWERStale leaderRefresh metadata, retry
UNKNOWN_TOPIC_OR_PARTITIONTopic not foundWait, retry
KAFKA_STORAGE_ERRORDisk errorWait, retry different replica

The ListOffsets API retrieves offsets by timestamp or special offset positions (earliest, latest).

VersionKafkaKey Changes
00.8.0Initial version (removed in 4.0)
10.10.1Single-offset response (4.0 baseline)
20.11.0Isolation level
42.1.0Leader epoch
52.2.0OFFSET_NOT_AVAILABLE
62.4.0Flexible versions
72.8.0MAX_TIMESTAMP (KIP-734)
83.4.0EARLIEST_LOCAL (KIP-405)
93.6.0LATEST_TIERED (KIP-1005)
103.8.0Remote list offsets (KIP-1075)
114.0.0EARLIEST_PENDING_UPLOAD (KIP-1023)
ListOffsetsRequest =>
replica_id: INT32
isolation_level: INT8
topics: [TopicRequest]
timeout_ms: INT32
TopicRequest =>
name: STRING
partitions: [PartitionRequest]
PartitionRequest =>
partition_index: INT32
current_leader_epoch: INT32
timestamp: INT64
FieldTypeDescription
replica_idINT32Replica ID (-1 for consumers)
isolation_levelINT80=read_uncommitted, 1=read_committed
timestampINT64Target timestamp or special value
timeout_msINT32Timeout for remote tiered reads (v10+)
ValueNameMeaning
-1LATESTLatest offset (log end offset)
-2EARLIESTEarliest offset (log start offset)
-3MAX_TIMESTAMPOffset of record with max timestamp (v7+)
-4EARLIEST_LOCALEarliest local log offset (v8+)
-5LATEST_TIEREDLatest tiered storage offset (v9+)
-6EARLIEST_PENDING_UPLOADEarliest pending upload offset (v11+)
≥0TimestampFirst offset with timestamp ≥ value
ListOffsetsResponse =>
throttle_time_ms: INT32
topics: [TopicResponse]
TopicResponse =>
name: STRING
partitions: [PartitionResponse]
PartitionResponse =>
partition_index: INT32
error_code: INT16
timestamp: INT64
offset: INT64
leader_epoch: INT32
FieldTypeDescription
timestampINT64Timestamp of returned offset (-1 if none)
offsetINT64Found offset
leader_epochINT32Leader epoch of returned offset
AspectGuarantee
Timestamp lookupReturns first offset where record timestamp ≥ requested
EARLIESTReturns log start offset
LATESTReturns high watermark (read_uncommitted) or LSO (read_committed)
Not foundReturns -1 for offset if no matching record

The Metadata API retrieves cluster topology, broker information, and topic/partition metadata.

VersionKafkaKey Changes
00.8.0Initial version
10.10.0Rack ID support
20.10.1Cluster ID
30.10.2Throttle time
40.11.0Topic-level errors
51.0.0Offline replicas
61.1.0Response before throttling
72.0.0Leader epoch
82.1.0Allow topic auto-create control
92.4.0Flexible versions
102.8.0Topic ID field (not implemented)
113.0.0Cluster authorized ops deprecated
123.4.0Topic ID supported
134.0.0Top-level error code
MetadataRequest =>
topics: [TopicRequest]
allow_auto_topic_creation: BOOLEAN
include_cluster_authorized_operations: BOOLEAN
include_topic_authorized_operations: BOOLEAN
TopicRequest =>
topic_id: UUID
name: NULLABLE_STRING
FieldTypeDescription
topicsARRAYTopics to fetch (null for all topics)
allow_auto_topic_creationBOOLEANAllow auto-creation of missing topics
include_cluster_authorized_operationsBOOLEANInclude cluster ACL info (v8-10)
include_topic_authorized_operationsBOOLEANInclude topic ACL info

Topic IDs are supported in v12+; v10-11 include the field but brokers do not implement it.

MetadataResponse =>
throttle_time_ms: INT32
brokers: [BrokerMetadata]
cluster_id: NULLABLE_STRING
controller_id: INT32
topics: [TopicMetadata]
cluster_authorized_operations: INT32
error_code: INT16
BrokerMetadata =>
node_id: INT32
host: STRING
port: INT32
rack: NULLABLE_STRING
TopicMetadata =>
error_code: INT16
name: STRING
topic_id: UUID
is_internal: BOOLEAN
partitions: [PartitionMetadata]
topic_authorized_operations: INT32
PartitionMetadata =>
error_code: INT16
partition_index: INT32
leader_id: INT32
leader_epoch: INT32
replica_nodes: [INT32]
isr_nodes: [INT32]
offline_replicas: [INT32]
FieldTypeDescription
controller_idINT32Current controller broker ID
cluster_idNULLABLE_STRINGCluster identifier
leader_idINT32Partition leader broker ID (-1 if none)
replica_nodesARRAYAll replica broker IDs
isr_nodesARRAYIn-sync replica broker IDs
offline_replicasARRAYOffline replica broker IDs
AspectGuarantee
CompletenessAll brokers the client may need to contact
FreshnessMay be slightly stale after topology changes
Auto-creationMay create topics if enabled and requested
Leader infoLeader may have changed since response

Metadata Staleness

Metadata responses may be stale. Clients must handle NOT_LEADER_OR_FOLLOWER errors by refreshing metadata and retrying.

BehaviorRecommendation
Cache metadata per clustershould
Refresh on NOT_LEADER errorsmust
Periodic refresh intervalmetadata.max.age.ms

The ApiVersions API queries the broker for supported API versions. It is the first API called during connection setup.

VersionKafkaKey Changes
00.10.0Initial version
10.10.1Throttle time
22.1.0Response before throttling
32.4.0Flexible versions
44.0.0SupportedFeatures min version fix
ApiVersionsRequest =>
client_software_name: STRING
client_software_version: STRING
FieldTypeDescription
client_software_nameSTRINGClient library name (v3+)
client_software_versionSTRINGClient library version (v3+)
ApiVersionsResponse =>
error_code: INT16
api_versions: [ApiVersion]
throttle_time_ms: INT32
supported_features: [SupportedFeature]
finalized_features_epoch: INT64
finalized_features: [FinalizedFeature]
zk_migration_ready: BOOLEAN
ApiVersion =>
api_key: INT16
min_version: INT16
max_version: INT16
FieldTypeDescription
api_keyINT16API identifier
min_versionINT16Minimum supported version
max_versionINT16Maximum supported version
BehaviorDescription
Pre-authenticationBroker must respond before SASL authentication
Version toleranceBroker should accept any valid request version
Error fallbackOn UNSUPPORTED_VERSION, client may try older version
ApiVersions negotiation before authenticationClientBrokerClientClientBrokerBrokerConnection EstablishedApiVersionsRequest(v3)No authentication yetalt[Version supported]ApiVersionsResponse(api_versions[])[Version not supported]UNSUPPORTED_VERSIONApiVersionsRequest(v0)ApiVersionsResponse(api_versions[])Client caches versioninfo for this broker
AspectGuarantee
AvailabilityMust be available before authentication
AccuracyVersion ranges must reflect actual capabilities
CompletenessMust include all supported APIs
ConsistencyShould not change during connection lifetime

KeyNameCategoryFirst Version
0ProduceCore0.8.0
1FetchCore0.8.0
2ListOffsetsCore0.8.0
3MetadataCore0.8.0
4LeaderAndIsrController0.8.0
5StopReplicaController0.8.0
6UpdateMetadataController0.8.0
7ControlledShutdownController0.8.0
8OffsetCommitConsumer0.8.1
9OffsetFetchConsumer0.8.1
10FindCoordinatorConsumer0.8.2
11JoinGroupConsumer0.9.0
12HeartbeatConsumer0.9.0
13LeaveGroupConsumer0.9.0
14SyncGroupConsumer0.9.0
15DescribeGroupsConsumer0.9.0
16ListGroupsConsumer0.9.0
17SaslHandshakeAuth0.10.0
18ApiVersionsCore0.10.0
19CreateTopicsAdmin0.10.1
20DeleteTopicsAdmin0.10.1
21DeleteRecordsAdmin0.11.0
22InitProducerIdTransaction0.11.0
23OffsetForLeaderEpochReplication0.11.0
24AddPartitionsToTxnTransaction0.11.0
25AddOffsetsToTxnTransaction0.11.0
26EndTxnTransaction0.11.0
27WriteTxnMarkersTransaction0.11.0
28TxnOffsetCommitTransaction0.11.0
29DescribeAclsAdmin0.11.0
30CreateAclsAdmin0.11.0
31DeleteAclsAdmin0.11.0
32DescribeConfigsAdmin0.11.0
33AlterConfigsAdmin0.11.0
34AlterReplicaLogDirsAdmin0.11.0
35DescribeLogDirsAdmin0.11.0
36SaslAuthenticateAuth1.0.0
37CreatePartitionsAdmin1.0.0
38CreateDelegationTokenAuth1.1.0
39RenewDelegationTokenAuth1.1.0
40ExpireDelegationTokenAuth1.1.0
41DescribeDelegationTokenAuth1.1.0
42DeleteGroupsConsumer1.1.0
43ElectLeadersAdmin2.2.0
44IncrementalAlterConfigsAdmin2.3.0
45AlterPartitionReassignmentsAdmin2.4.0
46ListPartitionReassignmentsAdmin2.4.0
47OffsetDeleteConsumer0.11.0
48DescribeClientQuotasAdmin2.6.0
49AlterClientQuotasAdmin2.6.0
50DescribeUserScramCredentialsAuth2.7.0
51AlterUserScramCredentialsAuth2.7.0
52VoteKRaft2.7.0
53BeginQuorumEpochKRaft2.7.0
54EndQuorumEpochKRaft2.7.0
55DescribeQuorumKRaft2.7.0
56AlterPartitionController2.7.0
57UpdateFeaturesAdmin2.7.0
58EnvelopeKRaft2.7.0
59FetchSnapshotKRaft3.0.0
60DescribeClusterAdmin3.0.0
61DescribeProducersAdmin3.0.0
62BrokerRegistrationKRaft3.0.0
63BrokerHeartbeatKRaft3.0.0
64UnregisterBrokerKRaft3.0.0
65DescribeTransactionsTransaction3.0.0
66ListTransactionsTransaction3.0.0
67AllocateProducerIdsKRaft3.0.0
68ConsumerGroupHeartbeatConsumer3.5.0
69ConsumerGroupDescribeConsumer3.5.0
70ControllerRegistrationKRaft3.5.0
71GetTelemetrySubscriptionsTelemetry3.5.0
72PushTelemetryTelemetry3.5.0
73AssignReplicasToDirsKRaft3.6.0
74ListConfigResourcesTelemetry3.6.0
75DescribeTopicPartitionsAdmin3.7.0
76ShareGroupHeartbeatShare4.0.0
77ShareGroupDescribeShare4.0.0
78ShareFetchShare4.0.0
79ShareAcknowledgeShare4.0.0
80AddRaftVoterKRaft4.0.0
81RemoveRaftVoterKRaft4.0.0
82UpdateRaftVoterKRaft4.0.0
83InitializeShareGroupStateShare4.0.0
84ReadShareGroupStateShare4.0.0
85WriteShareGroupStateShare4.0.0
86DeleteShareGroupStateShare4.0.0
87ReadShareGroupStateSummaryShare4.0.0
88StreamsGroupHeartbeatStreams4.0.0
89StreamsGroupDescribeStreams4.0.0
90DescribeShareGroupOffsetsShare4.0.0
91AlterShareGroupOffsetsShare4.0.0
92DeleteShareGroupOffsetsShare4.0.0