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
GET /topics/:topic_name/partitions/:partition?offset=(int)
Description : Consume messages from one partition of the topic.

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

POST /consumers/:group

Parameters:

     topic_name
  • group (String) -

topic
  • group name

     partition (int) - partition number
     offset (int) - offset to fetch

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
    •  partition Not Found

   500
  • 500 Internal Server Error

       Error
    • Error Code 50001 - Kafka Error

 


Example

...

request:

 

GET

POST /

consume

consumers/

test/partitions/1?offset=1

group/ 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, application/json

[

{

 

{    

"

key

name": "

a2V5

Instance1",

   

 "

value

format": "

dmFsdWU=

binary",

   "partition

 "auto.offset.reset":

1

"smallest",

   "offset": 1,

 },

 {

    "key": "a2V5",

   "value": "dmFsdWU=",

   "partition": 1,

   "offset": 2,

 }

]

 "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

Parameters:
     topic (String) - topic name
     group (String) - consumer group id

Response:
     JSON Object contains response objects

Status Codes:
    404 Not Found
         Error Code 40401 - topic Not Found
    500 Internal Server Error
         Error Code 50001 - Kafka Error

 

...

Example request:

 

POST /topics/testgroupgroup/offsets HTTP/1.1

Accept: application/vnd.kafka.v1+json

 

...

 

HTTP/1.1 200 OK

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


[

 {

   "topic": "topic",

   "partition": 1,

   "committed": 1

 },

 {

   "topic": "topic",

   "partition": 2,

   "committed": 2

 },

]

 

GET /topics/:topic_name/partitions/:partition?offset=(int)
Description : Consume messages from one partition of the topic.

Parameters:

     topic_name (String) - topic name
     partition (int) - partition number
     offset (int) - offset to fetch

Response:
    JSON Object contains response objects

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:

 

GET /consume/test/partitions/1?offset=1 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,

 }

]


 

Compatibility, Deprecation, and Migration Plan

...