Skip to content

Latest commit

 

History

History
59 lines (47 loc) · 2.22 KB

eventstreams025.md

File metadata and controls

59 lines (47 loc) · 2.22 KB
copyright lastupdated
years
2015, 2018
2018-05-25

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

Using the Kafka REST API

{: #rest_using}

** The Kafka REST API is available as part of the Standard plan only.**

The Kafka REST API provides a RESTful interface to a Kafka cluster. You can produce and consume messages by using the API. For more information including the API reference documentation, see Kafka REST Proxy 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](../../icons/launch-glyph.svg "External link icon")](http://docs.confluent.io/2.0.0/){:new_window} by adding the following line to the command line:
-H "X-Auth-Token: APIKEY"
{: codeblock}