copyright | lastupdated | ||
---|---|---|---|
|
2018-05-25 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}
{: #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 {: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}