Skip to content

Latest commit

 

History

History
54 lines (41 loc) · 2.15 KB

File metadata and controls

54 lines (41 loc) · 2.15 KB
copyright
years
2015, 2017
lastupdated 2017-10-26

{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}

Using the Kafka REST API

{: #rest_using}

The Kafka REST API provides a RESTful interface to a Kafka cluster. You can easily produce and consume messages and complete administration tasks by using the API. For reference documents, see Confluent Platform docs External link icon{:new_window}. Only the binary embedded format is supported for requests and responses in {{site.data.keyword.messagehub}}. The Avro and JSON embedded formats are not supported.

If you are using CURL, you can use an example like the following to produce:


curl -X POST -H "X-Auth-Token:APIKEY" -H "Content-Type: application/vnd.kafka.binary.v1+json" kafka-rest endpoint/topics/topic name -d 

'
{
  "records": [
    {
      "value": "A base 64 encoded value string"
    }
  ]
}
'

{: codeblock}

If you are using CURL, you can use an example like the following to consume:


curl -X GET -H "X-Auth-Token:APIKEY" -H "Accept: application/vnd.kafka.binary.v1+json" kafka-rest endpoint/topics/topic name/partitions/partition ID/messages?offset=offset to start from

{: codeblock}

For CURL, you can also adapt the code examples detailed in the Confluent docs External link icon{:new_window} by adding the following line to the command line:

-H "X-Auth-Token: APIKEY"

{: codeblock}