Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 

POST /topics/test/partitions/1 HTTP/1.1

Host:kafkarest.host.com

Content-Type: application/vnd.kafka.binary.v1+json

Accept: application/vnd.kafka.v1+json

{

  "records": [

   {

     "key": "a2V5",

     "value": "dmFsdWU="

   },

   {

     "value": "dmFsdWU="

   }

 ]

}


Example response:

 

HTTP/1.1 200 OK

 Content-Type: application/vnd.kafka.v1+json


{

 "offsets": [

   {

     "partition": 1,

     "offset": 1,

   },

   {

     "partition": 1,

     "offset": 2,

   }

 ]

}

Consumer API

 Description : Create a new consumer instance in the consumer group.

 

POST /consumers/:group

Parameters:

  • group (String) - group name

Request:

  • JSON Object contains name, dataformat, consumer properties.

Response:

  • JSON Object contains response objects.

  • Response includes a URL including the host since the consumer is stateful and tied to a specific REST proxy instance

Status Codes:

  • 404 Not Found

    • Error Code 40401 - topic Not Found

    • Error Code 40402 -  partition Not Found

  • 500 Internal Server Error

    • Error Code 50001 - Kafka Error


Example request:

 


POST /consumers/group/ HTTP/1.1

Accept: application/vnd.kafka.v1+json, application/vnd.kafka+json, application/json


{

 "name": "Instance1",

 "format": "binary",

 "auto.offset.reset": "smallest",

 "auto.commit.enable": "false"

}

 

Example response:

 


HTTP/1.1 200 OK

Content-Type: application/vnd.kafka.v1+json


{

 "id": "Instance1",

 "url": "http://kafkarest1.com/consumers/group/instances/Instance1"

}

 

GET /topics/:topic/messages?group=<group>

Description : consumes a message from the specified topic on behalf of the specified consumer group

 

GET /consumers/:group/:instance/:topic

Parameters:

     topic
  • topic (String) - topic name

     group
  • group (String) - consumer group id

  • Instance (string) - consumer instance name

Response:

     JSON
  • JSON Object contains response objects


Status Codes:

   
  • 404 Not Found

         Error Code 40401
    • Error Code 4040X - topic Not Found

   
    • Error Code 4040Y - group Not Found

    • Error Code 4040Z - instance Not Found

  • 500 Internal Server Error

         Error
    • Error Code 50001 - Kafka Error

 


Example

...

request:

 

GET /consumers/

topics

group/

test/messages?group=testgroup

instance1/topic HTTP/1.1

Accept: application/vnd.kafka.binary.v1+json

 

Example response:

 

HTTP/1.1 200 OK

Content-Type: application/vnd.kafka.binary.v1+json


[

 {

   "key": "a2V5",

   "value": "dmFsdWU=",

   "partition": 1,

   "offset": 1,

 },

 {

    "key": "a2V5",

   "value": "dmFsdWU=",

   "partition": 1,

   "offset": 2,

 }

]

 

Description : Commit offsets for the consumer instance associated with group.

 

POST /consumers/:group/:instance/offsets

 

Parameters:

  • group (String) - consumer group id

  • Instance (String) - consumer instance name


Response:

  • JSON Object contains response objects


Status Codes:

  • 404 Not Found

    • Error Code 40401 - group Not Found

    • Error Code 40402 - consumer instance Not Found

  • 500 Internal Server Error

    • Error Code 50001 - Kafka Error


Example request:

 

POST /consumers/group/instance1/offsets HTTP/1.1

Accept: application/vnd.kafka.v1+json

 

Example response:

 

HTTP/1.1 200 OK

Content-Type: application/vnd.kafka.v1+json


[

 {

   "topic": "test",

   "partition": 1,

   "committed": 100

 },

 {

   "topic": "test",

   "partition": 2,

   "committed": 200

 },

 {

   "topic": "test2",

   "partition": 1,

   "committed": 50

 }

]

 

...