tbulubas / kafka-rest

Confluent REST Proxy for Kafka

Home Page:https://docs.confluent.io/current/kafka-rest/docs/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kafka REST Proxy

The Kafka REST Proxy provides a RESTful interface to a Kafka cluster. It makes it easy to produce and consume messages, view the state of the cluster, and perform administrative actions without using the native Kafka protocol or clients. Examples of use cases include reporting data to Kafka from any frontend app built in any language, ingesting messages into a stream processing framework that doesn't yet support Kafka, and scripting administrative actions.


You can download prebuilt versions of the Kafka REST Proxy as part of the Confluent Platform.

You can read our full installation instructions and the complete documentation

To install from source, follow the instructions in the Development section below.


The REST proxy includes a built-in Jetty server and can be deployed after being configured to connect to an existing Kafka cluster.

Running mvn clean package runs all 3 of its assembly targets.

  • The development target assembles all necessary dependencies in a kafka-rest/target subfolder without packaging them in a distributable format. The wrapper scripts bin/kafka-rest-start and bin/kafka-rest-stop can then be used to start and stop the service.
  • The package target is meant to be used in shared dependency environments and omits some dependencies expected to be provided externally. It assembles the other dependencies in a kafka-rest/target subfolder as well as in distributable archives. The wrapper scripts bin/kafka-rest-start and bin/kafka-rest-stop can then be used to start and stop the service.
  • The standalone target packages all necessary dependencies as a distributable JAR that can be run as standard (java -jar $base-dir/kafka-rest/target/kafka-rest-X.Y.Z-standalone.jar).


The following assumes you have Kafka and an instance of the REST Proxy running using the default settings and some topics already created.

    # Get a list of topics
    $ curl "http://localhost:8082/topics"

    # Get info about one topic
    $ curl "http://localhost:8082/topics/jsontest"

    # Produce a message with JSON data
    $ curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" \
          --data '{"records":[{"value":{"name": "testUser"}}]}' \

    # Create a consumer for JSON data, starting at the beginning of the topic's
    # log. The consumer group is called "my_json_consumer" and the instance is "my_consumer_instance".
    $ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" -H "Accept: application/vnd.kafka.v2+json" \
    --data '{"name": "my_consumer_instance", "format": "json", "auto.offset.reset": "earliest"}' \
    # Subscribe the consumer to a topic
    $ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data '{"topics":["jsontest"]}' \
    # No content in response
    # Then consume some data from a topic using the base URL in the first response.

    $ curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" \
    # Finally, close the consumer with a DELETE to make it leave the group and clean up
    # its resources.  
    $ curl -X DELETE -H "Accept: application/vnd.kafka.v2+json" \
      # No content in response


To build a development version, you may need development versions of common, rest-utils, and schema-registry. After installing these, you can build the Kafka REST Proxy with Maven. All the standard lifecycle phases work.



This project is licensed under the Confluent Community License.


Confluent REST Proxy for Kafka




Language:Java 99.3%Language:Shell 0.6%Language:Dockerfile 0.0%