| copyright |
|
||
|---|---|---|---|
| lastupdated | 2017-10-26 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}
{: #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 {: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 {:new_window} by adding the following line to the command line:
-H "X-Auth-Token: APIKEY"
{: codeblock}