The Topics resource allows you to receive information about the topics in your Apache Kafka® cluster and their current state. It also lets you produce messages by making POST requests to specific topics.
GET / topics
Get a list of Apache Kafka® topics on the cluster.
This request allows you to produce messages to a topic, optionally specifying keys or partitions for the messages.
If no partition is provided, one will be chosen based on the key hash.
If no key is provided, the partition will be chosen for each message based in the schedule quota process (similar to round-robin ).
For the Avro , JSON Schema , and Protobuf embedded formats, provide information about schemas. You also need to configure the REST Proxy with the URL to access Schema Registry (schema.registry.url).
Schemas may be provided as the full schema encoded as a string. Alternatively, you can provide it as the schema ID returned with the first response after the initial request.
Parameters
Parameter
Data type
Description
topic_name
string
The name of the topic for which you want to produce messages
Request JSON object
Object
Data type
Description
key_schema
string
Full schema encoded as a string (for example, a serialized JSON for Avro schema)
key_schema_id
int
The identifier (ID) returned by a previous request that used the same schema. This ID corresponds to the ID of the schema in the registry.
value_schema
string
Full schema encoded as a string (for example, a serialized JSON for Avro schema)
value_schema_id
int
The identifier (ID) returned by a previous request that used the same schema. This ID corresponds to the ID of the schema in the registry.
The Partitions resource provides per-partition metadata, including the current leaders and replicas for each partition. It also allows you to consume and produce messages to a single partition using GET and POST requests.
GET topics / topic_name / partitions
This request allows you to get a list of partitions to the topic.
Parameters
Parameter
Data type
Description
topic_name
string
The name of the topic for which you want to get the list of partitions
Response JSON Array of Objects
Object
Data type
Description
partition
int
Partition ID
leader
int
Broker ID for the leader of the current partition
replicas
array
List of brokers acting as replicas for the current partition
replicas → broker
int
Broker ID of the replica
replicas → leader
bool
Returns true if the current broker is the leader of the current partition
replicas → in sync
bool
Returns true if the current replica is in sync with the leader
HTTP/1.1200 OK
Content-Type: application/vnd.kafka.v2+json
{
"beginning_offset": 10,
"end_offset": 50,
}
POST / topics / topic_name / partitions / partition_id
Produce messages to the specified partition of the topic.
For the Avro, JSON Schema, and Protobuf embedded formats, you must provide information about schemas. This may be provided as the full schema encoded as a string, or, after the initial request may be provided as the schema ID returned with the first response.
Parameters
Parameter
Data type
Description
topic_name
string
The name of the topic to which you want to produce messages
partition_id
int
ID of the partition for which you want to produce messages
Request JSON object
Object
Data type
Description
key_schema
string
Full schema encoded as a string (for example, a serialized JSON for Avro schema)
key_schema_id
int
The identifier (ID) returned by a previous request that used the same schema. This ID corresponds to the ID of the schema in the registry.
value_schema
string
Full schema encoded as a string (for example, a serialized JSON for Avro schema)
value_schema_id
int
The identifier (ID) returned by a previous request that used the same schema. This ID corresponds to the ID of the schema in the registry.
The ID of the schema used to produce keys, or null if no keys used
value_schema_id
int
THe ID of the schema used to produce values
Response JSON array of objects
Object
Data type
Description
offsets
object
List of offsets and partitions to which the messages were published
offsets → partition
int
The partition to which the message was published. This will be the same as the partition_id parameter and is provided only to maintain consistency with responses from producing to a topic
offsets → offset
long
The offset of the message, null if the message failed to publish
offsets → error_code
long
null if operation is successful or an error code classifying the failure type
offsets → error
string
null if successful or an error message with further information on the failure
The Consumers resource provides access to the current state of consumer groups, allowing you to do the following:
Create a consumer in a consumer group
Consume messages from topics and partitions.
REST Proxy can convert data stored in Apache Kafka® in serialized form into a JSON-compatible embedded format. We support the following formats:
Raw binary data as base64 strings
Avro data is converted into embedded JSON objects
JSON is embedded directly
Protobuf
JSON Schema
As consumers are stateful, any consumer instances created with the REST API are tied to a specific REST Proxy instance.
A full URL is provided when the instance is created and it should be used to construct any subsequent requests. Failing to use the returned URL for future consumer requests will result in 404 errors because the consumer instance will not be found.
If a REST Proxy instance is shut down, it will attempt to cleanly destroy any consumers before it's terminated.
POST / consumers / group_name
Create a new consumer instance in the specified consumer group.
Parameters
Parameter
Data type
Description
group_name
string
The name of the consumer group in which you want to create a new consumer instance
Request JSON object
Object
Data type
Description
name
string
Name of the consumer instance to create. Must be unique within the cluster. Leave it empty to generate an automatic name
format
string
The format of the consumed messages used to convert them into a JSON-compatible form. Possible values: avro, binary, json, jsonschema, protobuf.
auto.offset.reset
string
Sets the auto.offset.reset parameter for the consumer
auto.commit.enable
string
Sets the auto.commit.enableparameter for the consumer
fetch.min.bytes
string
Sets the fetch.min.bytes parameter for the consumer
consumer.request.timeout.ms
string
Sets the consumer.request.timeout parameter in milliseconds for the consumer
Response JSON object
Object
Data type
Description
instance_id
string
The unique ID of the consumer instance created in the specified group
base_uri
string
Base URI used in constructing the requests to the created consumer instance.
GET / consumers / group_name / instances / instance / records
Fetch data for the specified topics or partitions using one of the subscribe/assign APIs.
The format of the embedded data returned by this request is determined by the format specified in the initial consumer instance creation request and must match the format of the Accept header. Mismatches will result in error code 40601.
Note
You must make this request to the specific REST Proxy instance holding the consumer instance in question.
Parameters
Parameter
Data type
Description
group_name
string
The name of the consumer group
instance
string
The ID of the consumer instance
Query parameters
Parameter
Description
timeout
Maximum amount of milliseconds the REST Proxy will spend fetching records.
Other parameters controlling actual time spent fetching records:
max_bytes
fetch.min.bytes.
Default value: undefined.
This parameter is used only if it’s smaller than the consumer.timeout.ms defined either during consumer instance creation or in the REST Proxy’s configuration file.
max_bytes
The maximum number of bytes of unencoded keys and values to be included in the response.
This provides approximate control over the size of responses and the amount of memory required to store the decoded response.
The actual limit will be the minimum of this setting and the server-side configuration of consumer.request.max.bytes.